Skip to content

Instantly share code, notes, and snippets.

@onmyway133
Created April 24, 2019 13:21
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 onmyway133/3d6fbc63caa74713c719da2607ede32f to your computer and use it in GitHub Desktop.
Save onmyway133/3d6fbc63caa74713c719da2607ede32f to your computer and use it in GitHub Desktop.
public extension UIView {
func pinCenter(view: UIView) -> [NSLayoutConstraint] {
return [
centerXAnchor.constraint(equalTo: view.centerXAnchor),
centerYAnchor.constraint(equalTo: view.centerYAnchor)
]
}
func pin(size: CGSize) -> [NSLayoutConstraint] {
return [
widthAnchor.constraint(equalToConstant: size.width),
heightAnchor.constraint(equalToConstant: size.height)
]
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment