0

I move a button with an animation, if I use it inside a UIVIewController all work perfectly, if I try to subclassing a UIView with this animation I can't see it, the button appear into the end point but I don't see it moving. Where is the mistake?

This is my code:

- (void) moveButton:(UIButton *)button fromPoint:(CGPoint)startPoint toPoint:(CGPoint)endPoint {

        CGMutablePathRef thePath = CGPathCreateMutable();
        CGPathMoveToPoint(thePath, NULL, startPoint.x, startPoint.y);

        NSMutableArray *timings = [NSMutableArray array];
        NSMutableArray *keytimes = [NSMutableArray array];

        // Start
        [timings addObject:[self getTiming:kCAMediaTimingFunctionEaseIn]];
        [keytimes addObject:[NSNumber numberWithFloat:0.0]];

        // Bounce
        [timings addObject:[self getTiming:kCAMediaTimingFunctionEaseIn]];
        [keytimes addObject:[NSNumber numberWithFloat:1.0]];

        CAKeyframeAnimation * animation;
        animation = [CAKeyframeAnimation animationWithKeyPath:@"position"];
        animation.fillMode = kCAFillModeForwards;
        animation.removedOnCompletion = NO;
        animation.duration = 2;
        animation.path = thePath;
        animation.timingFunctions = timings;
        animation.keyTimes = keytimes;

        [[button layer] addAnimation:animation forKey:nil];
        [[button layer] setPosition:CGPointMake(endPoint.x,endPoint.y)];
    }
francesco.venica
  • 1,703
  • 2
  • 19
  • 54

0 Answers0