Skip to content

Instantly share code, notes, and snippets.

@yabenatti
Created September 26, 2020 15:45
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/d0d0da2f48a72e26c5995d0d350dee97 to your computer and use it in GitHub Desktop.
Save yabenatti/d0d0da2f48a72e26c5995d0d350dee97 to your computer and use it in GitHub Desktop.
Anchors Constraints
private func setupAnchorConstraints() {
view.addSubview(titleLabel)
view.addSubview(hiButton)
titleLabel.topAnchor.constraint(equalTo: view.topAnchor, constant: 20).isActive = true
titleLabel.leadingAnchor.constraint(equalTo: view.leadingAnchor, constant: 20).isActive = true
titleLabel.trailingAnchor.constraint(equalTo: view.trailingAnchor, constant: -20).isActive = true
hiButton.topAnchor.constraint(equalTo: titleLabel.bottomAnchor, constant: 8).isActive = true
hiButton.leadingAnchor.constraint(equalTo: view.leadingAnchor, constant: 20).isActive = true
hiButton.trailingAnchor.constraint(equalTo: view.trailingAnchor, constant: -20).isActive = true
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment