Skip to content

Instantly share code, notes, and snippets.

@Eluss
Created November 6, 2016 13:26
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 Eluss/c543b9f0ca1fb9e3beb7295da1ccaf29 to your computer and use it in GitHub Desktop.
Save Eluss/c543b9f0ca1fb9e3beb7295da1ccaf29 to your computer and use it in GitHub Desktop.
func pureLayout() {
scrollView.autoPinEdgesToSuperviewEdges(with: .zero)
scrollView.autoPinEdge(.bottom, to: .bottom, of: longer, withOffset: 20)
box.autoPinEdge(toSuperviewEdge: .top, withInset: 50)
box.autoPinEdge(.left, to: .left, of: self.view, withOffset: 20)
box.autoSetDimensions(to: CGSize(width: 100, height: 100))
circle.autoPinEdge(.top, to: .top, of: box)
circle.autoPinEdge(.right, to: .right, of: self.view, withOffset: -20)
circle.autoSetDimensions(to: CGSize(width: 100, height: 100))
longer.autoPinEdge(.left, to: .left, of: self.view, withOffset: 20)
longer.autoPinEdge(.right, to: .right, of: self.view, withOffset: -20)
longer.autoPinEdge(.top, to: .bottom, of: box, withOffset: 300)
longer.autoSetDimension(.height, toSize: 200)
}
func anchorLayout() {
scrollView.translatesAutoresizingMaskIntoConstraints = false
box.translatesAutoresizingMaskIntoConstraints = false
circle.translatesAutoresizingMaskIntoConstraints = false
longer.translatesAutoresizingMaskIntoConstraints = false
scrollView.rightAnchor.constraint(equalTo: view.rightAnchor).isActive = true
scrollView.topAnchor.constraint(equalTo: view.topAnchor).isActive = true
scrollView.leftAnchor.constraint(equalTo: view.leftAnchor).isActive = true
scrollView.bottomAnchor.constraint(equalTo: view.bottomAnchor).isActive = true
scrollView.bottomAnchor.constraint(equalTo: longer.bottomAnchor, constant: 20).isActive = true
box.topAnchor.constraint(equalTo: scrollView.topAnchor, constant: 50).isActive = true
box.leftAnchor.constraint(equalTo: view.leftAnchor, constant: 20).isActive = true
box.widthAnchor.constraint(equalToConstant: 100).isActive = true
box.heightAnchor.constraint(equalToConstant: 100).isActive = true
circle.topAnchor.constraint(equalTo: box.topAnchor).isActive = true
circle.rightAnchor.constraint(equalTo: view.rightAnchor, constant: -20).isActive = true
circle.widthAnchor.constraint(equalToConstant: 100).isActive = true
circle.heightAnchor.constraint(equalToConstant: 100).isActive = true
longer.leftAnchor.constraint(equalTo: view.leftAnchor, constant: 20).isActive = true
longer.rightAnchor.constraint(equalTo: view.rightAnchor, constant: -20).isActive = true
longer.topAnchor.constraint(equalTo: box.bottomAnchor, constant: 300).isActive = true
longer.heightAnchor.constraint(equalToConstant: 200).isActive = true
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment