【发布时间】:2014-08-30 01:14:03
【问题描述】:
下面的代码给我画了一个圆,如何修改现有的代码来画一个三角形呢?
_colorDotLayer = [CALayer layer];
CGFloat width = self.bounds.size.width-6;
_colorDotLayer.bounds = CGRectMake(0, 0, width, width);
_colorDotLayer.allowsGroupOpacity = YES;
_colorDotLayer.backgroundColor = self.annotationColor.CGColor;
_colorDotLayer.cornerRadius = width/2;
_colorDotLayer.position = CGPointMake(self.bounds.size.width/2, self.bounds.size.height/2);
【问题讨论】:
-
这种方法对绘制三角形没有用处。您应该查看 UIBezierPath 来做到这一点。
-
你也应该看看 CGContext。
-
SO 不是代码翻译服务。
标签: ios objective-c core-graphics