Make user defined attributes apply the CGColor datatype
suggest changeBy default, Interface Builder doesn’t accept the CGColor
datatype, so to allow adding a CGColor
using user defined attributes in interface builder; one may want to use an extension like this:
Swift Extension :
extension CALayer {
func borderUIColor() -> UIColor? {
return borderColor != nil ? UIColor(CGColor: borderColor!) : nil
}
func setBorderUIColor(color: UIColor) {
borderColor = color.CGColor
}
}
The new user defined attribute (borderUIColor) will be recognized and applied without problems.
![](/essential/ios/img/810a5e095fd33a5d5ceaf12bf505b84e3cf40989.png)
Found a mistake? Have a question or improvement idea?
Let me know.
Table Of Contents