Last active
March 2, 2019 13:26
-
-
Save nekonora/52473742f3d6d5359f473d387efdb3d6 to your computer and use it in GitHub Desktop.
UIView quick add programatically
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
addedView = UIView() | |
addSubview(addedView) | |
addedView.translatesAutoresizingMaskIntoConstraints = false | |
addConstraints([ | |
NSLayoutConstraint(item: addedView, attribute: .centerX, relatedBy: .equal, toItem: self, attribute: .centerX, multiplier: 1.0, constant: 0), | |
NSLayoutConstraint(item: addedView, attribute: .centerY, relatedBy: .equal, toItem: self, attribute: .centerY, multiplier: 1.0, constant: 0), | |
NSLayoutConstraint(item: addedView, attribute: .width, relatedBy: .equal, toItem: self, attribute: .width, multiplier: 1.0, constant: 0), | |
NSLayoutConstraint(item: addedView, attribute: .height, relatedBy: .equal, toItem: self, attribute: .height, multiplier: 1.0, constant: 0) | |
]) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment