I've been drawing my circles using Core Graphics, but I have recently started implementing xibs using the interface builder for my views. Is there anyway to draw a circle using the interface builder? Surprisingly, I couldn't find any other thread answering this question even though it sounds like a simple one.
Asked
Active
Viewed 4,801 times
1 Answers
6
There isn't per-se, but you can achieve this effect using a view's corner radius. This is performance-heavy however, so you should test on different devices and see the performance implications of this.
Xcode provides a "User Defined Runtime Attributes" section:
The format of this is key path and value.
You could set the layer.cornerRadius
keypath to half the width/height of the view. To help with performance, you can set the layer.shouldRasterize
key path to YES
.

Léo Natan
- 56,823
- 9
- 150
- 195
-
That's nifty. However it's not showing the circle in the interface builder – zaloo Feb 02 '14 at 01:53
-
No, it won't. Notice how the section is called "Runtime Attributes". These values are applied after decoding the view from the nib during runtime. – Léo Natan Feb 02 '14 at 01:54
-
Ah that makes sense. Is there an option for changing the color and alpha of the corners of the button? – zaloo Feb 02 '14 at 01:54
-
The layer has a `borderColor` property, but this you can only change in code, because it requires a `CGColor` object rather than `UIColor`. – Léo Natan Feb 02 '14 at 01:56
-
2I actually found a way to change it using interface builder, check this link out: http://stackoverflow.com/questions/12301256/is-it-possible-to-set-uiview-border-properties-from-interface-builder/17993890#17993890 – zaloo Feb 02 '14 at 02:16