一般在做自定义弹框时或者点击展示大图时用的较多。不说了上代码https://github.com/YST521/DEMOLIST.git
//第一步A页面跳转到B页面
MOdalPopController * popVC = [MOdalPopController new];
popVC.view.backgroundColor = [UIColor colorWithRed:0 green:0 blue:0 alpha:0.3];
popVC.modalPresentationStyle = UIModalPresentationOverCurrentContext;
self.modalPresentationStyle = UIModalPresentationCurrentContext;
[self presentAnimal]; //跳转动画
[self.navigationController presentViewController:popVC animated:NO completion:nil];
//
-(void)presentAnimal{
CATransition *animation = [CATransition animation];
animation.duration = 0.3;
animation.type = kCATransitionFade;
animation.subtype = kCATransitionFromTop;
[self.view.window.layer addAnimation:animation forKey:nil];
[self dismissViewControllerAnimated:NO completion:0];
}
//如果[self.navigationController presentViewController:popVC animated:NO completion:nil];里面动画为YES则是模态的那几种动画效果
B页面。dismiss 同样去掉了动画效果 重新添加了动画
-(void)dismiss{
CATransition *animation = [CATransition animation];
animation.duration = 0.3;
animation.type = kCATransitionFade;
animation.subtype = kCATransitionFromTop;
[self.view.window.layer addAnimation:animation forKey:nil];
[self dismissViewControllerAnimated:NO completion:0];
}