ios - UIButton 动画问题 - iOS

标签 ios xcode uibutton

我正在尝试处理 UIButton 动画,其中按钮移动到一个点,然后将隐藏设置为 true。然而,当我尝试使用以下代码时,该按钮甚至在动画完成之前就消失了。我做得正确吗?有什么建议吗?

[UIView animateWithDuration:0.8
                 animations:^{

                     selectedCurveIndex = 0;
                     [tradebutton moveTo:
                      CGPointMake(51,150) duration:0.8 
                                  option:curveValues[UIViewAnimationOptionCurveEaseInOut]];
                 }
                 completion:^(BOOL finished){ 

                     [tradeButton setHidden:TRUE];

                     UIStoryboard *storyboard = [UIStoryboard storyboardWithName:@"MainStoryboard_iPhone" bundle:nil];
                     UIViewController *vc = [storyboard instantiateViewControllerWithIdentifier:@"ButtonView"];

                     self.modalPresentationStyle = UIModalPresentationCurrentContext;
                     [self presentModalViewController:vc animated:NO];

                 }];

最佳答案

在继续之前,您需要确保将完成设置为

您的按钮隐藏得很快,因为 0.8 是一个很快的动画持续时间。您需要找到另一个位置来隐藏该按钮,或者您可以

试试这个:

[UIView animateWithDuration:0.8
                 animations:^{

                     selectedCurveIndex = 0;
                     [tradebutton moveTo:
                      CGPointMake(51,150) duration:0.8 
                                  option:curveValues[UIViewAnimationOptionCurveEaseInOut]];
                 }
                 completion:^(BOOL finished){ 

                     if ( finished ) 
                     {    
                         [tradeButton performSelector:@selector(setHidden:) withObject:@"YES" afterDelay:3.0];

                         UIStoryboard *storyboard = [UIStoryboard storyboardWithName:@"MainStoryboard_iPhone" bundle:nil];
                         UIViewController *vc = [storyboard instantiateViewControllerWithIdentifier:@"ButtonView"];

                         self.modalPresentationStyle = UIModalPresentationCurrentContext;
                         [self presentModalViewController:vc animated:NO];
                     }
                 }];

关于ios - UIButton 动画问题 - iOS,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/11642143/

相关文章:

ios - 1 个部分中带有随机重用标识符的 UICollectionView

iPhone 支持多种语言

ios - 无法从 JSONDecoder 获取数据,没错,我编的结构?

ios - 在用 Swift 编写的 Xcode 中的 iOS 应用程序中的 UITextView 中,将 UIButton 放置在文本的末尾

ios - 共享图片点击即可打开 URL

ios - 使用 if 语句将 tableViewController 插入 navigationController

objective-c - iOS 面朝上方向问题

iphone - 我需要释放这个对象吗?

ios - 我如何知道用户是否点击了按钮?

ios - IBoutlet 不适用于 xCode