如何翻转两个视图Objective C iOS 13

问题描述

我有两个翻转的视图(例如在卡上水平翻转)。 iOS 13已贬值了开始动画代码,我正在尝试找出如何使用[UIView animateWithDuration:delay:options:animations:completion:]

CGContextRef context = UIGraphicsGetCurrentContext();
[UIView beginAnimations:nil context:context];
[UIView setAnimationCurve:UIViewAnimationCurveEaseInOut];
[UIView setAnimationDuration:1.0];

[UIView setAnimationTransition: UIViewAnimationTransitionFlipFromLeft forView:self.ABCard cache:YES];

[self.ABCard exchangeSubviewAtIndex:0 withSubviewAtIndex:1];
[UIView setAnimationDelegate:self];
[UIView commitAnimations];

我正在尝试执行以下操作,但是动画只是在没有翻转动作的情况下立即切换视图。

 [UIView animateWithDuration:1.0 delay:1.0
                        options: UIViewAnimationCurveEaseInOut | UIViewAnimationTransitionFlipFromLeft
                     animations:^{
        [self.ABCard exchangeSubviewAtIndex:0 withSubviewAtIndex:1];
                           } completion:^(BOOL finished){
                           }];

解决方法

exchangeSubviewAtIndex不会更改动画的外观,因此不会产生动画,这就是为什么只看到它翻转的原因。

此答案的结果可能会帮助您找到适当的解决方案:iPhone Flip Animation using UIViewAnimationTransitionFlipFromLeft in landscape mode

相关问答

依赖报错 idea导入项目后依赖报错,解决方案:https://blog....
错误1:代码生成器依赖和mybatis依赖冲突 启动项目时报错如下...
错误1:gradle项目控制台输出为乱码 # 解决方案:https://bl...
错误还原:在查询的过程中,传入的workType为0时,该条件不起...
报错如下,gcc版本太低 ^ server.c:5346:31: 错误:‘struct...