present 半透明ViewController

作者: 博尔茨杰 | 来源:发表于2017-07-26 14:41 被阅读175次

最近项目有需求, 需要模态初一个半透明的视图,就像抖音APP的登录注册一样, 在目标视图中设置背景颜色然后发现模态动作结束后变成了黑色或者不是半透明的颜色

SecondViewController *seconVC = [[SecondViewController alloc] init];
seconVC.modalPresentationStyle = UIModalPresentationOverCurrentContext;//iOS8之后使用
seconVC.view.alpha = 0.4;
[self.navigationController presentViewController:seconVC animated:YES completion:^{
        
    }];

或者模态弹出NavigationViewController

SecondViewController *seconVC = [[SecondViewController alloc] init];
UINavigationController *nav = [[UINavigationController alloc] initWithRootViewController:seconVC];
nav.modalPresentationStyle = UIModalPresentationOverCurrentContext;
seconVC.view.alpha = 0.4;
[self.navigationController presentViewController:nav animated:YES completion:^{
        
}];

相关文章

网友评论

    本文标题:present 半透明ViewController

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