在iOS中隐藏UIButton的动画

pos*_*sha 1 iphone animation ios

在我的应用程序中,我想给动画UIButtons,就像按钮在隐藏时会"掉出"屏幕.

我尝试了以下代码,但它没有给我一个好结果.

[UIView animateWithDuration:1.5
                 animations:^{
                    S1Button.frame = CGRectMake(20, 10, 50, 10);
                }];
[S1Button setHidden:YES];
break;
Run Code Online (Sandbox Code Playgroud)

AtW*_*ork 6

您可以设置新位置并在动画后隐藏按钮.

  [UIView animateWithDuration:0.9 animations:^{
        tradeButton.frame = (CGRect){ CGPointMake(51, 150), tradeButton.bounds.size };
    } completion:^(BOOL finished) {
        tradeButton.hidden = YES;
        // etc.
    }];
Run Code Online (Sandbox Code Playgroud)