我想以轻微透明的背景将一个视图控制器模态呈现在当前视图上,使得第一个视图在模态视图下略微可见。
我设置了模态视图控制器的alpha值,并将modalPresentationStyle
设置为UIModalPresentationCurrentContext
,正如另一篇文章中建议的那样。
结果是,当动画向上播放时,视图的背景是透明的,但当视图控制器到位时,背景会变成不透明的黑色。在解散时它又变回透明的。
我该怎么让它在活动时保持透明?
我已在中进行过测试。我正在使用以下代码:
MyModalViewController *viewController = [[MyModalViewController alloc] init];
UINavigationController *navController = [[UINavigationController alloc] initWithRootViewController:viewController];
[navController setNavigationBarHidden:YES];
self.navigationController.modalPresentationStyle = UIModalPresentationCurrentContext;
[self.navigationController presentViewController:navController animated:YES completion:NULL];