【问题标题】:UIView above NavigationBar and StatusBarNavigationBar 和 StatusBar 上方的 UIView
【发布时间】:2016-10-25 14:49:57
【问题描述】:

我需要在 NavigationBar 和 StatusBar 上方以全屏模式显示 UIView 我该怎么做?


附:对不起我的英语

【问题讨论】:

    标签: swift uiview uinavigationbar uistatusbar


    【解决方案1】:

    下面的代码将帮助您。您可以将颜色更改为所需的颜色以达到所需的效果。

    UIWindow *window = [[[UIApplication sharedApplication] delegate] window];
    
    UIView *blue = [[UIView alloc] initWithFrame:[[UIScreen mainScreen] bounds]];
    [blue setBackgroundColor:[UIColor blueColor]];
    [window addSubview: blueView];
    

    Swift 代码:

    if let applicationDelegate:AppDelegate = UIApplication.shared.delegate as! AppDelegate? {
       if let window:UIWindow = applicationDelegate.window {
          let blueView:UIView = UIView(frame: UIScreen.main.bounds)
          blueView.backgroundColor = UIColor.blue.withAlphaComponent(0.75)
          window.addSubview(blueView)
       }
    }
    

    【讨论】:

    • @Eric Aya 我添加了代码的快速版本。感谢您的建议:)。如果还有什么可以做的,请随时发表评论
    【解决方案2】:

    你可能想看看这个人的答案。

    How to make a UIView that can cover the navigation bar?

    基本上,不是将第二个视图设置为主视图的子视图,而是将第二个视图设置为导航控制器的子视图。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多