模态与push导致弹出半透明背景不同

来源:互联网 发布:dota2第一滴血数据bug 编辑:程序博客网 时间:2024/06/08 17:01
 GroupViewController *gruop = [[GroupViewController alloc]init];    UINavigationController *nav = [[UINavigationController alloc]initWithRootViewController:gruop];    [self presentViewController:nav animated:YES completion:nil];

当使用这种方式进行模态跳转时,你获取到的

// 半透明背景    _bgImage= [[UIImageView alloc]initWithFrame:CGRectMake(0, 0, XBScreenWidth, XBScreenHeight)];    // 当前控制器的view    [[UIApplication sharedApplication].keyWindow.rootViewController.view addSubview:_bgImage];    _bgImage.backgroundColor = [UIColor blackColor];    _bgImage.alpha = 0.5;

[UIApplication sharedApplication].keyWindow.rootViewController.view
会是你模态跳转的那个界面。
主界面

如果你通过

GroupViewController *group = [[GroupViewController alloc]init];    [self.navigationController pushViewController:group animated:YES];

push , 半透明界面会显示在你当前的界面

当前界面

0 0