ボタンが画面にスライドするアニメーションを実装しました。ボタンが既に画面内にある場合は、ボタンを最初に外側にスライドさせてから、元に戻します。
ただし、最初のアニメーション (ボタンが既に画面にスライドされている場合) はスキップされるため、ボタンは画面の外に即座にジャンプして、スライドして戻ります。
ゆっくりと外に滑り出して、またゆっくりと滑り落ちてほしい。
setAnimationDuration
if-clause の内側のようなものは無視されます。
[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];