Here is the code
- (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];
}];
}
Run the code at device:ios 11 and ios 12 The animation that appears is synchronous, but the animation that disappears is instantaneous in iOS12