As part of an upcoming project, I’ve been playing around with drawing circular borders. I needed to find the most efficient way to programmatically draw these circles, since they’ll be appearing in really long table views. If you have any suggestions, or this code doesn’t work for you, get in touch on Twitter.

The following code will draw a thin, non-animated circular border around a view. (See below for drawing animated circles.)

Update: Thanks to @seanh for noting that startAngle needs to be Float(2 * M_PI), rather than 360.0.

And here’s another snippet of code I found and adapted to draw an animated circular border with Swift. Depending on the version of the beta you’re using, you might need to wrap some of the Floats in CGFloat()s.