Created
March 27, 2019 10:34
-
-
Save DenTelezhkin/f5af26ce3e8451e465c6d6baa84fa033 to your computer and use it in GitHub Desktop.
IBInspectable example for MLSDev blog articles
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
extension UIView { | |
@IBInspectable var cornerRadius: CGFloat { | |
get { return layer.cornerRadius } | |
set { | |
layer.cornerRadius = newValue | |
layer.masksToBounds = newValue > 0 | |
} | |
} | |
@IBInspectable var borderWidth: CGFloat { | |
get { return layer.borderWidth } | |
set { layer.borderWidth = newValue } | |
} | |
@IBInspectable var borderColor : UIColor { | |
get { return UIColor(CGColor: layer.borderColor ?? UIColor.whiteColor().CGColor } | |
set { layer.borderColor = newValue.CGColor } | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment