在iPhone中绘制空心圆 [英] Drawing Hollow circle in iPhone

查看:200
本文介绍了在iPhone中绘制空心圆的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我需要绘制以下图像

灰色部分是我想在另一个图像上绘制我需要使用CGContext方法使用的代码,我尝试使用CGContextAddArc但是失败了,因为当我填充笔划时,中心凹陷也填充了灰色纹理。

The Gray part is what i want to draw over another image what is the Code i need to use using CGContext methods, i tried using the CGContextAddArc but failed because when i fill the stroke the center hollow is also filled with the grey texture.

任何帮助表示赞赏。

信息:我有完整的蓝色图像,我需要添加蓝色图像上方的半圆

Info : I have the Complete Blue Image , i need to add the Semi Circle above the blue image

谢谢

推荐答案

进一步努力关于 Ole Begemann 在他的回答和修改中提到的内容,我能够达到要求。

Working further on what Ole Begemann referred in his answer and some modification , i was able to achieve the required.

CGContextRef context = UIGraphicsGetCurrentContext();
CGContextSetStrokeColorWithColor(context, [UIColor colorWithPatternImage:[UIImage imageNamed:@"background_grey_pattern.png"]].CGColor);
CGMutablePathRef path = CGPathCreateMutable();
CGContextSetLineWidth(context, 40);
CGPathAddArc(path, NULL, aRect.size.width/2, aRect.size.height/2, 45, 0*3.142/180, angle*3.142/180, 0);
CGContextAddPath(context, path);
CGContextStrokePath(context);
CGPathRelease(path);

因此,我只使用了一个弧线而不是2个弧线,并以更高的宽度抚摸它。

So instead of 2 arcs i used only one and stroked it with higher width.

希望这可以帮助其他人有相同的要求。

Hope this helps others having same requirement.

这篇关于在iPhone中绘制空心圆的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆