10
11
12
13
14
15
16
17
18
// 在当前路径下添加一个椭圆
路径
CGContextAddEllipseInRect(ctx, rectangle);
// 设置当前视图填充色
CGContextSetFillColorWithColor(ctx, [UIColor orangeColor].CGColor);
// 绘制当前路径区域
CGContextFillPath(ctx);
}
3、绘制三角形
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
// 绘制三角形
- (
void
)drawTriangle {
// 获取当前图形,视图推入堆栈的图形,相当于你所要绘制图形的图纸
CGContextRef ctx = UIGraphicsGetCurrentContext();
// 创建一个新的空图形路径。
CGContextBeginPath(ctx);
/**
* @brief 在指定点开始一个新的子路径 参数按顺序说明
*
* @param c 当前图形
* @param x 指定点的 x 坐标值
* @param y 指定点的 y 坐标值
*
*/
CGContextMoveToPoint(ctx, 160, 220);
/**
* @brief 在当前点追加直线段,参数说明与上面一样
*/
CGContextAddLineToPoint(ctx, 190, 260);
CGContextAddLineToPoint(ctx, 130, 260);
// 关闭并终止当前路径的子路径,并在当前点和子路径的起点之间追加一条线
CGContextClosePath(ctx);
找软件资料,就到一览软件文库