iOS _VC presentViewController:设置半透明

前言:时间忙,先把这个记下 ,有空再来补充。

  1. present一个ViewController
LHQDoorController *lagerPicVC = [[LHQDoorController alloc]init];
self.definesPresentationContext = YES;
lagerPicVC.modalPresentationStyle = UIModalPresentationOverCurrentContext;//关键语句,必须有 ios8 later
// 动画关闭 不然会有个半透明背景跟着动画 很丑..
[self presentViewController:lagerPicVC animated:NO completion:^{
// 根据 colorWithAlphaComponent:设置透明度,如果直接使用alpha属性设置,会出现Vc里面的子视图也透明.
   lagerPicVC.view.backgroundColor = [[UIColor whiteColor] colorWithAlphaComponent:0.5];
}];
  1. present 一个NavController
LHQDoorController *lagerPicVC = [[LHQDoorController alloc]init];
       lagerPicVC.view.backgroundColor = [[UIColor whiteColor] colorWithAlphaComponent:0.9f];
       NavController *doorNav = [[NavController alloc]initWithRootViewController:lagerPicVC];
       doorNav.view.backgroundColor = [UIColor clearColor];
//        self.definesPresentationContext = YES;
       doorNav.modalPresentationStyle = UIModalPresentationOverCurrentContext;//关键语句,必须有
       
       [self presentViewController:doorNav animated:NO completion:^{
       }];
最后编辑于
©著作权归作者所有,转载或内容合作请联系作者
【社区内容提示】社区部分内容疑似由AI辅助生成,浏览时请结合常识与多方信息审慎甄别。
平台声明:文章内容(如有图片或视频亦包括在内)由作者上传并发布,文章内容仅代表作者本人观点,简书系信息发布平台,仅提供信息存储服务。

相关阅读更多精彩内容

友情链接更多精彩内容