美文网首页
iOS _VC presentViewController:设置

iOS _VC presentViewController:设置

作者: wahkim | 来源:发表于2018-04-18 11:28 被阅读1164次

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

    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:^{
           }];
    

    相关文章

      网友评论

          本文标题:iOS _VC presentViewController:设置

          本文链接:https://www.haomeiwen.com/subject/jglvkftx.html