ios绘图基本图形之三角形

 1     // 1.获取图形上下文
 2     CGContextRef ctx =  UIGraphicsGetCurrentContext();
 3     
 4     // 2. 绘制三角形
 5     // 设置起点
 6     CGContextMoveToPoint(ctx, 100, 10);
 7     // 设置第二个点
 8     CGContextAddLineToPoint(ctx, 50, 100);
 9     // 设置第三个点
10     CGContextAddLineToPoint(ctx, 150, 100);
11     // 设置终点
12     //    CGContextAddLineToPoint(ctx, 100, 10);
13     // 关闭起点和终点
14     CGContextClosePath(ctx);
15     // 3.渲染图形到layer上
16     CGContextStrokePath(ctx);

 

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