1.在ios7以前:
UIViewController *VC = [[UIViewController alloc]init];
self.modalPresentationStyle = UIModalPresentationCurrentContext;//关键
[self presentViewController:VC animated:YES completion:nil];
2.iOS8以后的方法:使用UIModalPresentationOverCurrentContext
UIViewController *VC = [[UIViewController alloc]init];
VC.modalPresentationStyle = UIModalPresentationOverCurrentContext;//关键
//UIModalPresentationOverFullScreen全屏效果
[self presentViewController:VC animated:YES completion:nil];
3.可使用该方式判断系统版本
CGFloat versin = [[UIDevice currentDevice].systemVersion floatValue];
本文介绍了在不同iOS版本中实现模态视图控制器的方法。对于iOS 7及更早版本,采用UIModalPresentationCurrentContext;对于iOS 8及之后的版本,则使用UIModalPresentationOverCurrentContext。此外,还提供了检查当前设备系统版本的方法。
213

被折叠的 条评论
为什么被折叠?



