ios绘图基本图形之圆形

 

 1 - (void)drawRect:(CGRect)rect
 2 {
 3 
 4     // 1.获取上下文
 5     CGContextRef ctx = UIGraphicsGetCurrentContext();
 6     // 画圆
 7     CGContextAddArc(ctx, 100, 100, 50, 0, 2 * M_PI, 0);
 8 
 9     // 3.渲染 (注意, 画线只能通过空心来画)
10 //    CGContextFillPath(ctx);
11     CGContextStrokePath(ctx);
12 
13 }

or

 1 - (void)drawRect:(CGRect)rect
 2 {
 3 
 4     // 画圆
 5     // 1.获取上下文
 6     CGContextRef ctx = UIGraphicsGetCurrentContext();
 7     // 2.画圆
 8     CGContextAddEllipseInRect(ctx, CGRectMake(50, 100, 50, 50));
 9     
10     [[UIColor greenColor] set];
11     
12     // 3.渲染
13     //    CGContextStrokePath(ctx);
14     CGContextFillPath(ctx);
15 
16 }

 

posted @ 2016-01-22 15:22  xiaocaoera  阅读(363)  评论(0编辑  收藏  举报