繁体   English   中英

如何使用 UIBezierPath 制作曲线?

[英]How to make curve using UIBezierPath?

如何使用 UIBezierPath 绘制如图所示的曲线?

在此处输入图片说明

初始化路径。

UIBezierPath *aPath = [UIBezierPath bezierPath];

CGFloat xPos = 100.0;
CGFloat yPos = 50.0;
CGFloat width = 200;
CGFloat height = 200;

CGPoint controlPoint = CGPointMake(10.0, 10.0);

// Set the starting point of the shape.
[aPath moveToPoint:CGPointMake(xPos, yPos)];
[aPath moveToPoint:CGPointMake(xPos, width)];

// Draw the lines.
[aPath addLineToPoint:CGPointMake(width, height)];

//Add your arc here
[aPath addCurveToPoint:CGPointMake(xPos, height) controlPoint1:controlPoint controlPoint2:CGPointZero]

[aPath addLineToPoint:CGPointMake(xPos, yPos)];

//Close the Path
[aPath closePath];

试试上面的代码。 这不是经过测试的代码,我不在我的系统中。 通过调整控制点,可以增加圆弧的半径。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM