Create a circle in xib for interface builder

core-graphics, ios, objective-c, user-interface, xcode

Solution

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`.

Problem

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.

Original source

Related problems