I have a problem with lineWidth
when drawing different shapes in an UIView. All the shapes in the attached pictured should have a lineWidth of 3. Here's the code i used:
var path:UIBezierPath = UIBezierPath()
path.moveToPoint(CGPoint(x: 0.0, y: 0.0))
path.addLineToPoint(CGPoint(x: 0.0, y: 50.0))
path.lineWidth = 3.0
path.stroke()
As you can see in the pic, only the circle has the true stroke size of 3px. The hands of the clock are all 2px (this is why they're badly aligned).
Can you help me please?
I figured it out, so i'll post the answer for anyone interested. The line stroke is drawn on every side of the shape. So, in my case, i started drawing at a point (0,0) to (0,50). The left side was clipped, and only the right side was being drawn. Changing the code to
path.moveToPoint(CGPoint(x: 1.0, y: 0.0))
path.addLineToPoint(CGPoint(x: 1.0, y: 50.0))
resolved the problem.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With