0

我想知道是否可以创建一个 UIButton 动画以使按钮在屏幕中快速滑动,在到达中心时减速,然后加速并在另一侧退出屏幕。该按钮不必按下,所以我使用:

userInteractionEnabled = NO;

这是我试图做的:

UIButton* buttonNumberCountTutorial = [UIButton buttonWithType:UIButtonTypeRoundedRect];
[buttonNumberCountTutorial setTitle:@"2" forState:UIControlStateNormal];
[buttonNumberCountTutorial setTitleColor:[UIColor whiteColor] forState:UIControlStateNormal];
[buttonNumberCountTutorial.titleLabel setFont:[UIFont fontWithName:@"Zapfino" size:40]];
buttonNumberCountTutorial.frame = CGRectMake(-400, 430, 400, 400);
[buttonNumberCountTutorial setBackgroundImage:[UIImage imageNamed:@"socialize-navbar-bg.png"]forState:UIControlStateNormal];
[baseView addSubview:buttonNumberCountTutorial];
[UIView animateWithDuration:1.9f
                 animations:^{

        buttonNumberCountTutorial.frame = CGRectMake(20, 430, 200, 200);

        }
              completion:^(BOOL finished){

                  [buttonNumberCountTutorial removeFromSuperview];
    }];
4

1 回答 1

2

您可以定义动画选项。为您提供有趣的选择

UIViewAnimationOptionCurveEaseInOut
UIViewAnimationOptionCurveEaseIn 
UIViewAnimationOptionCurveEaseOut
UIViewAnimationOptionCurveLinear

您需要使用 UIView 的以下 Class 方法才能使用这些选项

+ (void)animateWithDuration:(NSTimeInterval)duration delay:(NSTimeInterval)delay options:(UIViewAnimationOptions)options animations:(void (^)(void))animations completion:(void (^)(BOOL finished))completion

当然,您可以通过在完成块中启动新动画来制作嵌套动画。

于 2013-03-27T15:57:30.400 回答