Bob
Bob

Reputation: 8714

Run some code at the end of UIBezierPath addLineToPoint

I am trying to run some script after addLineToPoint of UIBezierPath animation is done.

This is the piece of my code

    UIBezierPath *path = [UIBezierPath bezierPath];

    CGRect pathRect = CGRectInset(self.animationLayer.bounds, 0.0f, 0.0f);    
// define cgpoint
    CGPoint number1 = CGPointMake(CGRectGetMinX(pathRect), CGRectGetMaxY(pathRect));
    [path addLineToPoint: number1];

Here I found the reference for UIBezierClass, but I can't find any indicator that animation addLineToPoint is done. Thanks in advance. http://developer.apple.com/library/ios/#documentation/uikit/reference/UIBezierPath_class/Reference/Reference.html

Upvotes: 1

Views: 636

Answers (1)

David Rönnqvist
David Rönnqvist

Reputation: 56625

There is no animation involved in addLineToPoint. The same is true for all the other methods for constructing a UIBezierPath.

If you check the documentation the method you are talking about is under the section "Constructing a Path". All it does is add a line to the point in the model (it's not even drawn on screen yet).

You can draw the entire bezier path by calling fill or stroke on it inside a drawRect:method of some view but that won't animate anything either.


It sounds to me that you want to both animate the stroking of that path and get a callback when it is done. If so, you should create a CAShapeLayer and assign your bezier path to its path property. Then you can animate the stroking of that shape layer by animating the strokeEnd property from 0 to 1. If you configure yourself to be the delegate of that animation then you will get a animationDidStop:finished: callback once the animation is finished.

Upvotes: 4

Related Questions