[英]iOS opaque UIViewController on top of UINavigationController
我正在尝试从UINavigationController呈现不透明的UIViewController。 在对视图进行动画处理时,正如我所希望的那样它是不透明的。 但是,完成动画制作后,背景变为灰色。 当上一个视图是UIViewController时,我已经开始工作了。 当我使用UINavigationController作为上一个视图时,我开始遇到此问题。
切换查看的代码:
UIStoryboard *storyBoard = [UIStoryboard storyboardWithName:STORYBOARD_IPHONE bundle:nil];
UIViewController *viewController = [storyBoard instantiateViewControllerWithIdentifier:viewName];
[self presentViewController:viewController animated:YES completion:nil];
使呈现的视图不透明的代码:
self.view.backgroundColor = [[UIColor whiteColor] colorWithAlphaComponent:0.7];
我认为这可能与以下事实有关:呈现视图的类不是UINavigationController,而是UINavigationController中的UIViewController。 所以我尝试使用self.navigationController presentViewController,但是得到了相同的结果。
如何解决此问题,使背景保持不透明?
以前的UINavigationController带有嵌入式UIViewController:
动画期间的外观:
动画后的外观:
我经常使用以下例程查看哪些视图位于我感兴趣的视图后面:
// useful debugging method - send it a view and it will log all subviews
// can be called from the debugger
- (void) viewAllSubviews:(UIView *) topView Indent:(NSString *) indent {
for (UIView * theView in [topView subviews]){
NSLog(@"%@%@", indent, theView);
if ([theView subviews] != nil)
[self viewAllSubviews:theView Indent: [NSString stringWithFormat:@"%@ ",indent]];
}
}
我通常将其放在可以全局访问的位置。 像这样称呼它
[self viewAllSubviews:rootViewController.view Indent:@" "];
它将基于您提供给它的任何视图的根视图树打印到控制台,并根据级别缩进子视图。 它应该显示您感兴趣的对象背后的内容,并且您可以检查那里每个视图的帧坐标。
这应该为您提供背后的观点的一个很好的线索。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.