Ответ 1
Есть много способов сделать это, но нужно просто нарисовать два пути безье, по одному для каждой стороны:
- (void)drawRect:(CGRect)rect
{
UIBezierPath *blueHalf = [UIBezierPath bezierPath];
[blueHalf addArcWithCenter:CGPointMake(100, 100) radius:90.0 startAngle:-M_PI_2 endAngle:M_PI_2 clockwise:YES];
[blueHalf setLineWidth:4.0];
[[UIColor blueColor] setStroke];
[blueHalf stroke];
UIBezierPath *redHalf = [UIBezierPath bezierPath];
[redHalf addArcWithCenter:CGPointMake(100, 100) radius:90.0 startAngle:M_PI_2 endAngle:-M_PI_2 clockwise:YES];
[redHalf setLineWidth:4.0];
[[UIColor redColor] setStroke];
[redHalf stroke];
}
Или, если вы хотите сделать это в Core Graphics:
- (void)drawRect:(CGRect)rect
{
CGContextRef context = UIGraphicsGetCurrentContext();
CGContextSetLineWidth(context, 4);
CGContextSetStrokeColorWithColor(context, [[UIColor blueColor] CGColor]);
CGContextAddArc(context, 100, 100, 90, -M_PI_2, M_PI_2, FALSE);
CGContextStrokePath(context);
CGContextSetStrokeColorWithColor(context, [[UIColor redColor] CGColor]);
CGContextAddArc(context, 100, 100, 90, M_PI_2, -M_PI_2, FALSE);
CGContextStrokePath(context);
}