【问题标题】:Navigationbar not filling under status bar when clicked from side menu?从侧面菜单单击时,导航栏未填充在状态栏下?
【发布时间】:2017-10-05 13:08:16
【问题描述】:

我有一个由导航控制器为我的视图创建的导航栏,这些导航栏是通过容器侧菜单加载的。

当我单击一个项目时,它会加载导航控制器和视图,但导航栏背景会消失,在状态栏上显示空白背景颜色。

知道如何诊断此问题吗?我已经包含了一些视图调试器屏幕截图来最好地说明

  UINavigationBar.appearance().tintColor = UIColor.white
    UINavigationBar.appearance().barTintColor = UIColor().appThemeColour()
    UINavigationBar.appearance().isTranslucent = false
    UINavigationBar.appearance().shadowImage = UIImage()
    UINavigationBar.appearance().titleTextAttributes = [NSForegroundColorAttributeName : UIColor.white]
    UIApplication.shared.statusBarStyle = .lightContent

【问题讨论】:

  • 你在使用 SideMenu pod 吗?
  • 您是否在某处移除导航栏阴影?
  • 我正在使用 interactivesidemenu github.com/handsomecode/InteractiveSideMenu
  • 现在将我的导航配置外观添加到 OP 中
  • 是状态栏背景色还是导航栏背景色的问题?

标签: ios swift uinavigationbar statusbar


【解决方案1】:

你在这里错过了一件事,那就是 UINavigationBar 的 setBackgroundImage。

    UINavigationBar.appearance().tintColor = UIColor.white
    UINavigationBar.appearance().barTintColor = UIColor().appThemeColour()
    UINavigationBar.appearance().isTranslucent = false
    UINavigationBar.appearance().shadowImage = UIImage()
    UINavigationBar.appearance().setBackgroundImage(UIImage(), for: .default)
    UINavigationBar.appearance().titleTextAttributes = [NSForegroundColorAttributeName : UIColor.white]
    UIApplication.shared.statusBarStyle = .lightContent

【讨论】:

  • 不幸的是,这对问题没有影响,我认为它更多地与影响它的侧面菜单有关
【解决方案2】:

*注意这是名为“https://github.com/jonkykong/SideMenu/”的 Sidemenu 库的解决方案

将状态栏结束 alpha 属性更改为 0

【讨论】:

    【解决方案3】:

    请在下面找到代码。

    @objcMembers
    open class SideMenuPresentationStyle: InitializableClass {
    
    /// Background color behind the views and status bar color
    
    open var backgroundColor: UIColor = .white`
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2014-07-03
      • 1970-01-01
      • 2021-01-19
      • 1970-01-01
      • 2017-10-07
      • 1970-01-01
      • 2015-11-13
      相关资源
      最近更新 更多