-(void)bounceTheViewVertically:(UIView*)view
{
CGPoint origin = view.center;
CGPoint target = CGPointMake(view.center.x, view.center.y-50);
CABasicAnimation *bounce = [CABasicAnimation animationWithKeyPath:@"position.y"]; //Animations for y axis
bounce.duration = 0.5;
bounce.fromValue = [NSNumber numberWithInt:origin.y];
bounce.toValue = [NSNumber numberWithInt:target.y];
bounce.repeatCount = 2;
bounce.autoreverses = YES; // undo changes after Animations.
[view.layer addAnimation: bounce forKey:@"position"];
}
No comments:
Post a Comment