UIKit
//设置圆弧宽度 path.lineWidth = 10;
//设置颜色 [[UIColor redColor] set];
//矩形
UIBezierPath *path = [UIBezierPath bezierPathWithRect:CGRectMake(20, 20, 30, 200)];
[path stroke];
//圆形
UIBezierPath *path = [UIBezierPath bezierPathWithOvalInRect:CGRectMake(20, 20, 200, 200)];
[path stroke];
// 圆角矩形
UIBezierPath *path = [UIBezierPath bezierPathWithRoundedRect:CGRectMake(20, 20, 200, 200) cornerRadius:100];
[path stroke];
// 圆弧
// Center:圆心 // startAngle:弧度 // clockwise:YES:顺时针 NO:逆时针
UIBezierPath *path = [UIBezierPath bezierPathWithArcCenter:CGPointMake(125, 125) radius:100 startAngle:0 endAngle:M_PI_2 clockwise:YES];
[path stroke];
// 扇形
CGPoint center = CGPointMake(125, 125);
UIBezierPath *path = [UIBezierPath bezierPathWithArcCenter:center radius:100 startAngle:0 endAngle:M_PI_2 clockwise:YES];
// 添加一根线到圆心 [path addLineToPoint:center];
// 封闭路径,关闭路径:从路径的终点到起点 // [path closePath];
// [path stroke];
// 填充:必须是一个完整的封闭路径,默认就会自动关闭路径 [path fill];