Warning: file_get_contents(/data/phpspider/zhask/data//catemap/5/objective-c/26.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Ios 如何创建具有两种不同颜色的自定义圆形UIView?_Ios_Objective C_Uiview_Draw - Fatal编程技术网

Ios 如何创建具有两种不同颜色的自定义圆形UIView?

Ios 如何创建具有两种不同颜色的自定义圆形UIView?,ios,objective-c,uiview,draw,Ios,Objective C,Uiview,Draw,有没有一种方法可以创建两种不同颜色的圆形UIView, 像这样: 应该按照您在图像(边框)上看到的那样分割圆。子类UIView并实现drawRect:方法 以下是开始绘制圆的代码: - (void)drawRect:(CGRect)rect { CGContextRef ctx = UIGraphicsGetCurrentContext(); CGContextAddEllipseInRect(ctx, rect); CGContextSetFillColor(ctx,

有没有一种方法可以创建两种不同颜色的圆形UIView, 像这样:


应该按照您在图像(边框)上看到的那样分割圆。

子类
UIView
并实现
drawRect:
方法

以下是开始绘制圆的代码:

- (void)drawRect:(CGRect)rect
{
    CGContextRef ctx = UIGraphicsGetCurrentContext();
    CGContextAddEllipseInRect(ctx, rect);
    CGContextSetFillColor(ctx, CGColorGetComponents([[UIColor blueColor] CGColor]));
    CGContextFillPath(ctx);
}
另外,看看