Quartz2D简单绘制之不规则形状

View Code
// 画不规则形状
CGContextRef contextRef = UIGraphicsGetCurrentContext();
CGContextSetRGBStrokeColor(contextRef, 1.0f, 1.0f, 1.0f, 1); // 填充时用不到
CGContextSetLineWidth(contextRef, 2.0f); // 填充时用不到
CGFloat components[] = { 1.0f, 0.0f, 0.0f, 1.0f};
CGContextSetFillColor(contextRef, components);
CGContextMoveToPoint(contextRef, 150.0f, 150.0f);
CGContextAddLineToPoint(contextRef, 200.0f, 170.0f);
CGContextAddLineToPoint(contextRef, 180.0f, 300.0f);
CGContextAddLineToPoint(contextRef, 80.0f, 300.0f);
CGContextClosePath(contextRef);
//CGContextFillPath(contextRef); // 填充
CGContextStrokePath(contextRef); // 不填充



posted on 2011-12-04 00:30  uniy  阅读(362)  评论(0编辑  收藏  举报

导航