center-vfl icon indicating copy to clipboard operation
center-vfl copied to clipboard

Not work on Mac

Open cool8jay opened this issue 8 years ago • 1 comments

only get an empty window after applying the constraints. :(

cool8jay avatar Jun 08 '16 15:06 cool8jay

Hi @cool8jay, thanks for reporting. I have managed to center a text field on OS X. First, I created the text field programmatically using the function below and then applied the same auto layout method as I did for iOS.

private func createLabel() -> NSTextField {
    let label = NSTextField()
    label.translatesAutoresizingMaskIntoConstraints = false
    label.stringValue = "I am centered!"
    label.backgroundColor = NSColor.yellowColor()
    label.bezeled = false
    label.editable = false
    return label
}

Here is a demo OS X app.

OSXLayoutCostraintsTest.zip

evgenyneu avatar Jun 08 '16 21:06 evgenyneu