如何绘制填充的多边形?
答
你可以用UIKit
(即更高级别API),这样做也:
UIBezierPath *path = [UIBezierPath ...];
...
[UIColor.redColor setFill];
[path fill];
这将填补你的路上,我目前的图形上下文。
+0
谢谢。但是没有办法制作圆角。似乎你的代码和Trisha一样。 AFAIK,Android上的CornerPathEffect(int radius)类。此路径效果绘制圆角路径。任何建议像iPhone的CornerPathEffect?谢谢。 – Ferdinand
答
- (void)drawRect:(CGRect)rect{
CGContextRef context= UIGraphicsGetCurrentContext();
CGContextSetRGBStrokeColor(context, 0.0, 1.0, 0.0, 1.0);
CGContextSetLineWidth(context, 1.0);
CGContextMoveToPoint(context, 10, 50);
CGContextAddLineToPoint(context, 100, 80);
CGContextAddLineToPoint(context, 120, 120);
CGContextAddLineToPoint(context, 60, 80);
CGContextAddLineToPoint(context, 10, 50);
CGContextSetFillColorWithColor(context, [UIColor redColor].CGColor);
CGContextFillPath(context);
}
+0
谢谢。但是没有办法制作圆角。特丽莎'你的代码绘制一个形状作为第一张照片。 AFAIK,Android上的CornerPathEffect(int radius)类。此路径效果绘制圆角路径。任何建议像iPhone的CornerPathEffect?谢谢。 – Ferdinand
如果您想提供更多详细信息,请在个别答案下使用评论,或编辑您的问题。 –