0
votes

In my app, I manage to draw a line with uibezierpath and add it to the sublayer of a view, and after I manage to apply some transformation on this view rotate the view and change the size thanks to UIRotationGestureRecognizer and UIPinchGestureRecognizer. The problem is that, when I change the size of the view with UIPinchGestureRecognizer, the thickness of my line also changed, and I don't manage to keep the same thickness.

Actually, what I try to do is to draw an arrow and be able to move it, rotate it and resize it. I manage to do that, but the thickness of my arrow change when I pinch the view :)

Is it possible to avoid that ?

Thanks :)

1
You will need to change the lineWidth of the bezier path to scale appropriately with the scale of the pinch.keithbhunter
Thanks it works. I just tought there was an easiest way :)Adz
I'm having the same issue, but don't know how to implement it. Can you help?Aнгел

1 Answers

0
votes

Swift4:

let path = UIBezierPath() 
    path.move(to: CGPoint(x: 100, y: 100))
    path.addLine(to: CGPoint(x: 150, y: 150))
    path.stroke()

let traingle = CAShapeLayer()
    traingle.path = path.cgPath
    traingle.fillColor = UIColor.gray.cgColor
    traingle.setAffineTransform(CGAffineTransform(rotationAngle: .pi))
 self.view.layer.addSublayer(triangle)