0

I write this code :

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)) 

and this show me this in my storyboard:

Story Board

but I want this :

what I want

If anyone have the solution, I think my trouble is where I draw the Arc... Thanks for your help

1
  • Is the start and end angles flipped? Commented Jul 10, 2018 at 20:50

1 Answer 1

1

The first point and the arc were incorrect. You need:

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)) 
Sign up to request clarification or add additional context in comments.

2 Comments

If you're inspecting the path in a playground or the debugger, it's drawn in the usual mathematical geometry where y increases up. If you draw it in graphics context created by UIKit (e.g. UIGraphicsImageRenderer), it's drawn in the usual UIKit geometry where y increases down.
@robmayoff with UIGraphicsImageRendererFormat.default() ?

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.