iosdev iosdev - 7 months ago 47
iOS Question

Jumping effect on uibuttons

Here in my app i used the moving sub View.If it reach y=150,i want to make a buttons in jumping effect,i tried this link adding bounce effect to appearance of UIImageView it working in horizontal direction ,i want a vertical direction,Here my code,

if ( < 150) = CGPointMake(, +5);
if( ==150)
[UIView beginAnimations:@"bounce" context:nil];
[UIView setAnimationRepeatCount:3];
[UIView setAnimationRepeatAutoreverses:YES];
CGAffineTransform transform = CGAffineTransformMakeScale(1.3,1.3);
bt1.transform = transform;
[UIView commitAnimations];

Please help me to change into jumping effect(vertically)?


Try this. You can make some changes so it suits your need,

        CABasicAnimation *anim = [CABasicAnimation animationWithKeyPath:@"transform"];
        anim.timingFunction = [CAMediaTimingFunction functionWithName:kCAMediaTimingFunctionEaseInEaseOut];
        anim.duration = 0.125;
        anim.repeatCount = 1;
        anim.autoreverses = YES;
        anim.removedOnCompletion = YES;
        anim.toValue = [NSValue valueWithCATransform3D:CATransform3DMakeScale(1.2, 1.2, 1.0)];
        [senderView.layer addAnimation:anim forKey:nil];

Hope this helps.