iOS _VC presentViewController:设置

2018-04-18  本文已影响1164人  wahkim

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

  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:^{
       }];
上一篇下一篇

猜你喜欢

热点阅读