I have three Swift Classes:
@IBDesignable class CustomTextField : UITextField {
@IBInspectable var borderColor: UIColor = UIColor.clearColor() {
didSet {
layer.borderColor = borderColor.CGColor
}
}
}
@IBDesignable class CustomView : UIView {
@IBInspectable var borderColor: UIColor = UIColor.clearColor() {
didSet {
layer.borderColor = borderColor.CGColor
}
}
}
@IBDesignable class CustomButton : UIButton {
@IBInspectable var borderColor: UIColor = UIColor.clearColor() {
didSet {
layer.borderColor = borderColor.CGColor
}
}
}
All three classes have the same computed property (borderColor). I want to be DRY (don't repeat yourself) and have such repeated computed properties or methods inherited from somewhere. Is there a way to do that?
I know there's a way to do this with protocol extensions and default implementations of protocol methods - but it doesn't seem so clean: