Skip to content

Instantly share code, notes, and snippets.

@michaelevensen
Last active November 17, 2016 10:39
Show Gist options
  • Save michaelevensen/7bdcc5bad7d557a4db16195b4083b4bb to your computer and use it in GitHub Desktop.
Save michaelevensen/7bdcc5bad7d557a4db16195b4083b4bb to your computer and use it in GitHub Desktop.
Simple IBDesignable template for a UIView with customizable cornerRadius, strokeWidth and strokeColor.
@IBDesignable
class RoundedView: UIView {
@IBInspectable var roundedValue: CGFloat = 0.0 {
didSet {
layer.cornerRadius = roundedValue
}
}
@IBInspectable var strokeWidth: CGFloat = 0.0 {
didSet {
layer.borderWidth = strokeWidth
}
}
@IBInspectable var strokeColor: UIColor = UIColor.clear {
didSet {
layer.borderWidth = strokeWidth
layer.borderColor = strokeColor.cgColor
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment