Bright Future Bright Future - 1 year ago 166
Swift Question

Setting line cap style doesn't work UIBezierPath

This is my code:

let cross = UIBezierPath()
cross.move(to: CGPoint(x: skull.bounds.maxX, y: skull.bounds.minY))
cross.addLine(to: CGPoint(x: skull.bounds.minX, y: skull.bounds.maxY))
cross.lineWidth = 3.0
cross.lineCapStyle = .round

I want to round the end of the line, but it's still square, how should I do it?

Answer Source

just tested on PlayGround, Hope it will help

let cross = UIBezierPath()
cross.moveToPoint(CGPoint(x: 10, y: 100)) // your point
cross.addLineToPoint(CGPoint(x: 100, y: 10)) // your point
cross.lineWidth = 23.0
cross.lineJoinStyle = .Round


enter image description here

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download