IOS 直线绘制

//1.创建贝塞尔路径的实例

UIBezierPath*path = [UIBezierPathbezierPath];

//2.勾勒一个图形

//移动画笔

[pathmoveToPoint:CGPointMake(50,50)];

//加一条线到260 260的位置

[pathaddLineToPoint:CGPointMake(250,50)];

[pathaddLineToPoint:CGPointMake(250,150)];

[pathaddLineToPoint:CGPointMake(50,150)];

//[path addLineToPoint:CGPointMake(50, 50)];

//[path closePath];

//[path moveToPoint:CGPointMake(50, 200)];

//[path addLineToPoint:CGPointMake(250, 200)];

//[path addLineToPoint:CGPointMake(250, 350)];

//[path addLineToPoint:CGPointMake(50, 350)];

//[path closePath];

//3.设置描边色填充色

[[UIColorredColor]setStroke];

[[UIColorgreenColor]setFill];

//设置描边的宽度

path.lineWidth=10;

//焦点的样式

/*

kCGLineJoinMiter,

kCGLineJoinRound,

kCGLineJoinBevel

*/

path.lineJoinStyle=kCGLineJoinBevel;

//线两端的样式

/*

kCGLineCapButt,

kCGLineCapRound,

kCGLineCapSquare

*/

path.lineCapStyle=kCGLineCapSquare;

//4.描边及填充

[pathstroke];

//[path fill];

你可能感兴趣的:(IOS 直线绘制)