繁体   English   中英

如何添加子视图来覆盖UINavigation barin UIViewController?

[英]How to add a subview to cover UINavigation barin UIViewController?

您好我想在我当前的视图控制器上添加一个UIView 所以我确实喜欢这个。

- (void)viewDidLayoutSubviews
{

    UIView *vwOverlay=[[UIView alloc] initWithFrame:self.view.frame];
   [vwOverlay setBackgroundColor:[UIColor blackColor]];
   [vwOverlay setAlpha:0.5];
   [self.view addSubview:vwOverlay];
}

但这是添加我的视图的顶部,但在我的导航栏后面。还可以清楚地看到导航栏标题和导航菜单项,还可以单击导航栏项。 但我想从我的新视图中覆盖此导航栏。 我怎样才能做到这一点? 请帮我。 谢谢

使用此代码

UIWindow *window = [[UIApplication sharedApplication] keyWindow];
CGSize screenBounds = [UIScreen mainScreen].bounds;
UIView *vwOverlay=[[UIView alloc] initWithFrame: screenBounds];
[vwOverlay setBackgroundColor:[UIColor blackColor]];
[vwOverlay setAlpha:0.5];
[window addSubview:vwOverlay];

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM