ストーリーボードに UIButton を設定しました。これを押すと、UIVIew がアニメーション化されます。同じボタンを2回目に押したときに、UIViewを元の位置にアニメーション化/移動したいと思います。
これを行う最善の方法は何ですか?
助けや指針をありがとう。
これは、UIVIew をアニメーション化して移動するために使用しているコードです。
buttonCurrentStatus という名前の BOOL を使用しています。
-(IBAction)sortDeals:(UIButton*)sender {
if (buttonCurrentStatus == NO)
{
buttonCurrentStatus = YES;
CGRect menuTopFrame = self.menuTop.frame;
menuTopFrame.origin.y = 30;
[UIView beginAnimations:nil context:nil];
[UIView setAnimationDuration:0.5];
[UIView setAnimationDelay:0.0];
[UIView setAnimationCurve:UIViewAnimationCurveEaseOut];
self.menuTop.frame = menuTopFrame;
[UIView commitAnimations];
NSLog(@"Sort Deals touched button status = yes");
} else {
buttonCurrentStatus = NO;
CGRect menuTopFrame = self.menuTop.frame;
menuTopFrame.origin.y = 30;
[UIView beginAnimations:nil context:nil];
[UIView setAnimationDuration:0.5];
[UIView setAnimationDelay:0.0];
[UIView setAnimationCurve:UIViewAnimationCurveEaseOut];
self.menuTop.frame = menuTopFrame;
[UIView commitAnimations];
NSLog(@"Sort Deals touched button status = no");
}