Is it possible to set UIView border properties from interface builder?

matteo.cajani picture matteo.cajani · Sep 6, 2012 · Viewed 153k times · Source

Is it possible to control UIView border properties (color, thickness, etc...) directly from interface builder or I can only do it programmatically?

Answer

Rich86man picture Rich86man · Apr 5, 2013

Actually you can set some properties of a view's layer through interface builder. I know that I can set a layer's borderWidth and cornerRadius through xcode. borderColor doesn't work, probably because the layer wants a CGColor instead of a UIColor.

You might have to use Strings instead of numbers, but it works!

layer.cornerRadius
layer.borderWidth
layer.borderColor

Update: layer.masksToBounds = true

example

Update: select appropriate Type for Keypath:

enter image description here