在我的应用程序中,我使用了移动 subview 。如果它达到 y=150,我想制作一个跳跃效果的按钮,我试过这个链接 adding bounce effect to appearance of UIImageView 它在水平方向工作,我想要一个垂直方向,这是我的代码,

-(void)godown
 {
if (movingview.center.y < 150) movingview.center = CGPointMake(movingview.center.x, movingview.center.y +5);
if(movingview.center.y ==150)
{
  [UIView beginAnimations:@"bounce" context:nil];
  [UIView setAnimationRepeatCount:3];
  [UIView setAnimationRepeatAutoreverses:YES];
  CGAffineTransform transform = CGAffineTransformMakeScale(1.3,1.3);
  bt1.transform = transform;
  bt2.transform=transform;
 [UIView commitAnimations];
}
}

请帮我变成跳跃效果(垂直)?

最佳答案

试试这个。您可以进行一些更改以适合您的需要,

        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];

希望这可以帮助。

关于iphone - uibuttons 上的跳跃效果,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/12968301/

10-12 03:04