Created
February 19, 2018 17:13
-
-
Save azamsharp/5baa99d142b878c1ba0ae3026dc663ee to your computer and use it in GitHub Desktop.
This file contains hidden or 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
| extension UIView { | |
| func addToParent(view :UIView) -> UIView { | |
| view.addSubview(self) | |
| return self | |
| } | |
| func bottomMargin(from view: UIView, margin :CGFloat) -> UIView { | |
| self.bottomAnchor.constraint(equalTo: view.bottomAnchor, constant: margin).isActive = true | |
| return self | |
| } | |
| func centerX(in view: UIView) -> UIView { | |
| self.centerXAnchor.constraint(equalTo: view.centerXAnchor).isActive = true | |
| return self | |
| } | |
| func setWidth(width :CGFloat) -> UIView { | |
| self.widthAnchor.constraint(equalToConstant: width).isActive = true | |
| return self | |
| } | |
| func setHeight(height : CGFloat) -> UIView { | |
| self.heightAnchor.constraint(equalToConstant: height).isActive = true | |
| return self | |
| } | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment