Mohamad Bachir Sidani
Mohamad Bachir Sidani

Reputation: 2099

How do I draw a triangle with a corner radius?

I am trying to draw a triangle like this one exactly enter image description here

Can someone guide me how to achieve this as I tried a lot with no success?

my worst case scenario is to use a image but I don't want to do that.

Thanks a lot!

Upvotes: 0

Views: 2120

Answers (1)

DungeonDev
DungeonDev

Reputation: 1226

Maybe you should try this:

let trianglePath = UIBezierPath()
trianglePath.lineJoinStyle = .round
trianglePath.lineWidth = 25
trianglePath.move(to: CGPoint(x: 5.0, y: 10.0)) 
trianglePath.addLine(to: CGPoint(x: 130, y: 280.0)) 
trianglePath.addLine(to: CGPoint(x: 265.0, y: 10.0)) 
trianglePath.close()

That gives you this in Playground: enter image description here

Upvotes: 2

Related Questions