Reputation: 7092
I'm designing a new button for an app, I'd like to avoid coding as I have to use the same button style through the app. I added some attributes and it works fine, but when I add a border color (doesn't matter which color) for no reason the border disappears. What is going on?
Upvotes: 2
Views: 2113
Reputation: 5967
You can not set some properties of a view's layer through interface builder. You can set a layer's borderWidth
and cornerRadius
via Interface Builder
tool of Xcode
, but you will not be able to set borderColor using Interface Builder
and it's probably because the layer.borderColor
wants a CGColor
instead of a UIColor
. And unfortunately, there's no way to assign a CGColorRef
type in Interface Builder
.
You can programmatically set the button's border color on its layer as-
[[button layer] setBorderColor:[UIColor redColor].CGColor];
Upvotes: 2
Reputation: 13520
layer.borderColor
requires a CGColorRef
but the color set using the Interface Builder is of UIColor
type. That is the reason borderColor
is not showing on your button.
You'll have to set it programmatically.
Upvotes: 1