Last active
March 15, 2017 18:31
-
-
Save berkcebi/d6d76e0e6b6103149e8897f7d8a72bfa to your computer and use it in GitHub Desktop.
Nib-free layout code sample
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Defining the appearance while creating the property. | |
let editButton: NSButton = { | |
let button = NSButton() | |
button.bordered = false | |
button.setButtonType(.MomentaryChange) | |
button.image = NSImage(named: "icEdit") | |
button.alternateImage = NSImage(named: "icEditSelected") | |
return button | |
}() | |
… | |
// Declaring Auto Layout constraints with Cartography. | |
constrain(view, editButton, self) { view, editButton, superview in | |
editButton.left == view.right | |
editButton.right <= superview.right - View.margin | |
editButton.centerY == view.centerY | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment