我写这段代码:
let leftUpPath = UIBezierPath()
leftUpPath.move(to: CGPoint(x: 40, y: 40))
leftUpPath.addArc(withCenter: CGPoint(x: 40, y: 40),
radius: 10,
startAngle: CGFloat(Double.pi),
endAngle: CGFloat(3*Double.pi),
clockwise: true)
leftUpPath.addLine(to: CGPoint(x: 30, y: 50))
leftUpPath.addLine(to: CGPoint(x: 90, y: 50))
leftUpPath.addLine(to: CGPoint(x: 80, y: 30))
leftUpPath.addLine(to: CGPoint(x: 40, y: 30))
这个在我的故事板上给我看:
但我想要这个:
如果有人有办法的话,我想我的麻烦就在我画弧线的地方。。。谢谢你的帮助
最佳答案
第一个点和弧不正确。你需要:
let leftUpPath = UIBezierPath()
leftUpPath.move(to: CGPoint(x: 40, y: 30))
leftUpPath.addArc(withCenter: CGPoint(x: 40, y: 40),
radius: 10,
startAngle: .pi * 3 / 2,
endAngle: .pi,
clockwise: false)
leftUpPath.addLine(to: CGPoint(x: 30, y: 50))
leftUpPath.addLine(to: CGPoint(x: 90, y: 50))
leftUpPath.addLine(to: CGPoint(x: 80, y: 30))
leftUpPath.addLine(to: CGPoint(x: 40, y: 30))