石英弧、填充、描边和路径
)
我必须创建一些位于圆圈一侧的自定义按钮(如右侧图像上的示例:http://dribbble.com/shots/352571-Game-UI-Bottom-Left)
我尝试使用以下代码创建基本形状:
CGContextSetLineWidth(context, 2.0);
CGContextAddArc(context, 200, 200, 100, -M_PI_4, M_PI + M_PI_4, 1);
CGContextAddArc(context, 200, 200, 60, M_PI + M_PI_4,-M_PI_4 , 0);
CGContextClosePath(context);
CGContextSetFillColorWithColor(context, [UIColor redColor].CGColor);
CGContextFillPath(context);
CGContextAddArc(context, 200, 200, 100, -M_PI_4, M_PI + M_PI_4, 1);
CGContextAddArc(context, 200, 200, 60, M_PI + M_PI_4,-M_PI_4 , 0);
CGContextClosePath(context);
CGContextSetStrokeColorWithColor(context, [UIColor blackColor].CGColor);
CGContextStrokePath(context);
我从来没有做过一些核心图形(只有一些小东西,比如画一个圆圈之类的东西......)。令人惊讶的是,为了抚摸形状并使其疼痛,我必须重新创建路径。 我想有一些很聪明的方法可以做到这一点,对吗? ;) 因为我在这里,所以我必须在这个形状上绘制一些渐变,以防万一它使整个事情变得复杂;) 谢谢你的帮助
)
I've got to create a few custom buttons that will be on the side of a circle (like this example on the right hand side image : http://dribbble.com/shots/352571-Game-UI-Bottom-Left)
I tried to create the basic shape using this code :
CGContextSetLineWidth(context, 2.0);
CGContextAddArc(context, 200, 200, 100, -M_PI_4, M_PI + M_PI_4, 1);
CGContextAddArc(context, 200, 200, 60, M_PI + M_PI_4,-M_PI_4 , 0);
CGContextClosePath(context);
CGContextSetFillColorWithColor(context, [UIColor redColor].CGColor);
CGContextFillPath(context);
CGContextAddArc(context, 200, 200, 100, -M_PI_4, M_PI + M_PI_4, 1);
CGContextAddArc(context, 200, 200, 60, M_PI + M_PI_4,-M_PI_4 , 0);
CGContextClosePath(context);
CGContextSetStrokeColorWithColor(context, [UIColor blackColor].CGColor);
CGContextStrokePath(context);
I've never done some Core Graphics yet (only small stuff like drawing a circle and stuff...). It seems surprising tha in order to stroke the shape and pain it, I have to recreate the path.
I guess there are some much clever ways to do this right? ;)
Since I'm here, I will have to draw some gradients in this shape, just in case it complicates the whole stuff ;)
Thanks for you help
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
查看以下函数来创建单个路径:
...为了性能,如果要多次绘制该路径,请记住缓存该路径!
Check out the following functions to create a single path:
...and for performance, remember to cache this path if you're going to draw it multiple times!