最近项目有需求, 需要模态初一个半透明的视图,就像抖音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:^{
}];