Skip to content

Instantly share code, notes, and snippets.

@fpg1503
Last active April 19, 2017 11:54
Show Gist options
  • Save fpg1503/4e416757f7fc6700fa1b5f9029592973 to your computer and use it in GitHub Desktop.
Save fpg1503/4e416757f7fc6700fa1b5f9029592973 to your computer and use it in GitHub Desktop.
Cartography Boilerplate
import Cartography
final class <#Name#>View: UIView {
init() {
super.init(frame: .zero)
self.buildViews()
}
required init?(coder aDecoder: NSCoder) {
super.init(coder: aDecoder)
self.buildViews()
}
private func buildViews() {
addSubviews()
formatViews()
addConstraintsToSubviews()
}
//TODO: Subviews constants
private func addSubviews() {
//TODO Add subviews
}
private func formatViews() {
//TODO: Format views
}
private func addConstraintsToSubviews() {
//TODO: Cartography Constraints
}
override func didMoveToSuperview() {
super.didMoveToSuperview()
guard let superview = superview else {
return
}
constrain(self, superview) { view, superview in
view.edges == superview.edges
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment