I am trying to add a subpath to my CAShapeLayer path, but the changes are not displayed unless I first passed nil to the path and then reassigned myPath to CAShapeLayer . I tried with setNeedsRedisplay , but it does not work.
This is the code in LoadView , where myPath and shapeLayer are properties:
And this, for example, when I make changes along the way. I just add a new subpath to myPath :
- (void)handleOneFingerSingleTapGesture:(UIGestureRecognizer *)sender { // I add a new subpath to 'myPath' CGPathMoveToPoint(myPath, nil, self.view.center.x, self.view.center.y); CGPathAddLineToPoint(myPath, nil, self.view.center.x + 100.0, self.view.center.y + 100.0); // I must do this to show the changes shapeLayer.path = nil; shapeLayer.path = myPath; }
Does anyone know how to deal with this ?. I am using iOS 5.0.
source share