Skip to content

Instantly share code, notes, and snippets.

@pedrommcarrasco
Created January 6, 2019 20:10
Show Gist options
  • Save pedrommcarrasco/11ad48d9a90e66d5586c01b43b14f261 to your computer and use it in GitHub Desktop.
Save pedrommcarrasco/11ad48d9a90e66d5586c01b43b14f261 to your computer and use it in GitHub Desktop.
Guide Your Layout - Constraints
NSLayoutConstraint.activate(
[
layoutGuide.centerYAnchor.constraint(equalTo: view.centerYAnchor),
layoutGuide.leadingAnchor.constraint(equalTo: view.leadingAnchor),
layoutGuide.trailingAnchor.constraint(equalTo: view.trailingAnchor),
photoImageView.topAnchor.constraint(equalTo: layoutGuide.topAnchor),
photoImageView.centerXAnchor.constraint(equalTo: layoutGuide.centerXAnchor),
photoImageView.widthAnchor.constraint(equalTo: photoImageView.heightAnchor),
photoImageView.heightAnchor.constraint(equalToConstant: 250),
introLabel.topAnchor.constraint(equalTo: photoImageView.bottomAnchor, constant: 16),
introLabel.bottomAnchor.constraint(equalTo: layoutGuide.bottomAnchor),
introLabel.leadingAnchor.constraint(equalTo: photoImageView.leadingAnchor),
introLabel.trailingAnchor.constraint(equalTo: photoImageView.trailingAnchor)
]
)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment