如何使用UIBezierPath制作曲线?

时间:2016-09-16 23:10:50

标签: swift swift3 core-graphics uibezierpath

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

enter image description here

1 个答案:

答案 0 :(得分:0)

初始化路径。

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

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