I Set CornerRadius and BorderWidth for UIbutton in User Defined Runtime Attributes. Without adding layer.borderColor it works Well and Display border in bla
The explanation, perhaps being lost in some of the other answers here:
The reason that this property is not being set is that layer.borderColor
needs a value with type CGColor
.
But only UIColor
types can be set via Interface Builder's User Defined Runtime Attributes!
So, you must set a UIColor to a proxy property via Interface Builder, then intercept that call to set the equivalent CGColor to the layer.borderColor
property.
This can be accomplished by creating a Category on CALayer, setting the Key Path to a unique new "property" (borderColorFromUIColor
), and in the category overriding the corresponding setter (setBorderColorFromUIColor:
).