如何使用UIBezierPath制作曲线?

问题描述:

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

enter image description here

+1

有趣的问题。你有尝试过什么吗? – CivFan

+0

@CivFan我尝试了很多,但没有成功。我试图使用UIBezier路径的弧方法。 – milanpanchal

初始化路径。

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

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