码迷,mamicode.com
首页 > 移动开发 > 详细

ios绘图基本图形之三角形

时间:2016-01-22 17:56:45      阅读:152      评论:0      收藏:0      [点我收藏+]

标签:

 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);

 

ios绘图基本图形之三角形

标签:

原文地址:http://www.cnblogs.com/PJHome/p/5151348.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!