I am trying to set up a view's layer properties via IB. Everything works except for color of the border (property layer.borderColor
):
I remember running into this problem a year ago and I ended up doing it programatically. And still, I can do this programmatically, but I am curious why the layer.borderColor
property never works via interface builder. I don't want to import QuartzCore
, and then write extra line of code just because of this, seems like an overkill.
My two cents for porting Bartłomiej Semańczyk's answer to Swift:
Create an extension for CALayer in your view controller:
Copy and paste this class:
Now in Interface Builder, go to the Identity inspector and set your view as a CustomView class.
After that, check out your Attributes Inspector:
No need to mess around with user defined runtime attributes anymore. And your changes will also show up on the canvas!