Вот код
- (void)viewDidLoad {
[super viewDidLoad];
UIView *testView1 = [[UIView alloc] initWithFrame:CGRectMake(100, 100, 100, 100)];
UIView *testView2 = [[UIView alloc] initWithFrame:CGRectMake(100, 200, 100, 100)];
testView1.backgroundColor = [UIColor blueColor];
[self.view addSubview:testView1];
[self setView:testView1 hidden:YES];
testView2.backgroundColor = [UIColor redColor];
[self.view addSubview:testView2];
[self setView:testView2 alpha:0.f];
// Do any additional setup after loading the view, typically from a nib.
}
- (void)setView:(UIView *)view hidden:(BOOL)hidden {
[UIView transitionWithView:view duration:1.f options:UIViewAnimationOptionTransitionFlipFromLeft animations:^{
view.hidden = hidden;
} completion:^(BOOL finished) {
[self setView:view hidden:!hidden];
}];
}
- (void)setView:(UIView *)view alpha:(CGFloat)alpha {
[UIView transitionWithView:view duration:1.f options:UIViewAnimationOptionTransitionFlipFromLeft animations:^{
view.alpha = alpha;
} completion:^(BOOL finished) {
[self setView:view alpha:1.f - alpha];
}];
}
Запустите код на устройстве: IOS 11 и IOS 12
Анимация, которая появляется, является синхронной, но анимация, которая исчезает, является мгновенной в iOS12
![enter image description here](https://i.stack.imgur.com/2j4yg.png)
![enter image description here](https://i.stack.imgur.com/JvpZP.png)