【发布时间】:2013-03-27 15:51:13
【问题描述】:
我想知道是否可以创建一个 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];
}];
【问题讨论】:
-
我同意@Mert(“编译”他的意思是完成)。您可以在出现部分使用
UIViewAnimationOptionCurveEaseOut,在消失部分使用UIViewAnimationOptionCurveEaseIn(在原始完成块中插入的另一个动画中)。