我为我的按钮实现了一个动画以滑入屏幕。如果按钮已经在屏幕内,我希望我的按钮先滑到外面,然后再回来。
然而,第一个动画(当按钮已经滑入屏幕时)被跳过,因此按钮只是立即跳出屏幕而不是向后滑动。
我希望他们慢慢地滑到外面,然后再慢慢地滑回来。
它有点像setAnimationDuration
if 子句的内部被忽略:
[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];