I have a complex UIBezierCurve that I need to draw once with some specific line parameters, and then draw it again as an overlay with other line parameters, but I also need the last part of the curve to be slightly shorter than the previous one.
To do this, I want to create a curve on addLineToPoint: moveToPoint: to the last part, then make a copy of this curve and add the end segments of the line differently to the original and copied curves. And then I will stroke the original curve and copied.
The problem is that it does not work as I expected. I create a copy of the curve:
UIBezierPath* copyCurve = [originalCurve copy];
And the drawing that I make in originalCurve after that also applies to copyCurve, so I cannot make an independent drawing for any of these curves.
What is the reason for this connection between the original and the copy and how can I get rid of it?
EDIT 1: The solution I found is to create a copy as follows:
UIBezierPath* copyCurve=[UIBezierPath bezierPathWithCGPath:CGPathCreateMutableCopy(originalCurve.CGPath)];
Since this works correctly, perhaps the problem is the immutability of the copy that I get with
[originalCurve copy]
Bartonaz
source share