Skip to content

Instantly share code, notes, and snippets.

@DenTelezhkin
Created March 27, 2019 10:34
Show Gist options
  • Save DenTelezhkin/f5af26ce3e8451e465c6d6baa84fa033 to your computer and use it in GitHub Desktop.
Save DenTelezhkin/f5af26ce3e8451e465c6d6baa84fa033 to your computer and use it in GitHub Desktop.
IBInspectable example for MLSDev blog articles
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