UIButton移动动画
问题描述:
我想知道是否有可能创建一个UIButton动画,使按钮在屏幕上快速滑动,当它到达中心时变慢,然后加快速度并退出另一侧的屏幕。该按钮没有被按下,所以我用: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];
}];
答
您可以定义动画选项。你
UIViewAnimationOptionCurveEaseInOut
UIViewAnimationOptionCurveEaseIn
UIViewAnimationOptionCurveEaseOut
UIViewAnimationOptionCurveLinear
您需要使用下面的UIView类方法的有趣的选项,以便能够使用这些选项
+ (void)animateWithDuration:(NSTimeInterval)duration delay:(NSTimeInterval)delay options:(UIViewAnimationOptions)options animations:(void (^)(void))animations completion:(void (^)(BOOL finished))completion
当然,您也可以通过启动在完成一个新的动画制作嵌套动画块。
我同意@Mert(通过“汇编”他的意思是完成)。您可以在消失部分中使用'UIViewAnimationOptionCurveEaseOut'和在原始完成模块中插入另一个动画中的'UIViewAnimationOptionCurveEaseIn'。 – Levi 2013-03-27 16:07:07