Skip to content

Instantly share code, notes, and snippets.

@yabenatti
Created September 26, 2020 16:06
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save yabenatti/8e1c7fc59184be358b58ddbdaf35beb5 to your computer and use it in GitHub Desktop.
Save yabenatti/8e1c7fc59184be358b58ddbdaf35beb5 to your computer and use it in GitHub Desktop.
Cartography Constraints
import Cartography
private func setupWithCartography() {
view.addSubview(titleLabel)
view.addSubview(hiButton)
constrain(titleLabel, view) { label, superview in
label.top == superview.top + 20
label.leading == superview.leading + 20
label.trailing == superview.trailing - 20
}
constrain(hiButton, titleLabel, view) { button, label, superview in
button.top == label.bottom + 8
button.leading == superview.leading + 20
button.trailing == superview.trailing - 20
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment