Subclass uiview and implement drawRect
- (void)drawRect:(CGRect)rect { CGRect circleRect = self.bounds; CGFloat circleWidth = circleRect.size.width / 5.0; CGContextRef context = UIGraphicsGetCurrentContext(); CGContextSetFillColorWithColor(context, [[UIColor redColor] CGColor]); CGContextFillEllipseInRect(context, circleRect); circleRect = CGRectInset(circleRect, circleWidth, circleWidth); CGContextSetFillColorWithColor(context, [[UIColor whiteColor] CGColor]); CGContextFillEllipseInRect(context, circleRect); circleRect = CGRectInset(circleRect, circleWidth, circleWidth); CGContextSetFillColorWithColor(context, [[UIColor redColor] CGColor]); CGContextFillEllipseInRect(context, circleRect); }
Will draw

You must set that you look at the backgoundColor before [UIColor clearColor] to make it not black at the edges.
You can also tweak it in a loop, but this is the easiest code example I can show.
Note. I did not reuse colors, for simplicity of the arc / non-arc code
bigkm
source share