【发布时间】:2013-05-26 14:40:39
【问题描述】:
我实现了一个动画让我的按钮滑入屏幕。如果按钮已经在屏幕内,我希望我的按钮先滑到外面再滑回来。
但是第一个动画(当按钮已经滑入屏幕时)被跳过,以便按钮立即跳出屏幕 然后向后滑动。
我希望它们慢慢地滑到外面,然后再慢慢地滑回来。
有点像 if 子句中的 setAnimationDuration 被忽略:
[self.buttonInfoFrame setAlpha:1.0];
[self.buttonSetCourse setAlpha:1.0];
[self.buttonSetCourse setEnabled:YES];
if(![self.selected isEqual: @""])
{
CGRect frame = self.buttonInfoFrame.frame;
frame.origin.x = 1050;
frame.origin.y = 150;
CGRect frame2 = self.buttonSetCourse.frame;
frame2.origin.x = 1050;
frame2.origin.y = 526;
[UIView beginAnimations:nil context:nil];
[UIView setAnimationDuration:1.0];
self.buttonInfoFrame.frame = frame;
self.buttonSetCourse.frame = frame2;
[UIView commitAnimations];
}
CGRect frame = self.buttonInfoFrame.frame;
frame.origin.x = 757;
frame.origin.y = 150;
CGRect frame2 = self.buttonSetCourse.frame;
frame2.origin.x = 747;
frame2.origin.y = 526;
[UIView beginAnimations:nil context:nil];
[UIView setAnimationDuration:1.0];
self.buttonInfoFrame.frame = frame;
self.buttonSetCourse.frame = frame2;
[UIView commitAnimations];
【问题讨论】:
-
被选中的呢?一个布尔值、一个字符串等?
-
slideAnimation 是从 5 个不同的按钮调用的......它只是一个按下哪个按钮的标识符......如果在标识符为空之前没有按下任何按钮,所以我不必运行第一个动画。
标签: ios objective-c uibutton uiviewanimation