Ios 导航栏在模拟器中显示文本,但不显示故事板

Ios 导航栏在模拟器中显示文本,但不显示故事板,ios,xcode,Ios,Xcode,我的导航栏是透明的,只有导航栏按钮显示在我的应用程序中。在我的故事板中,我没有标题,所以导航栏看起来什么都没有,但是当我运行模拟器时,我删除的文本在导航栏中 这就是我发现的解决问题的方法: 如果没有透明度,导航栏应该是什么样子 导航条在模拟器中的外观 使条形图透明的代码: //Makes navigation bar translucent self.navigationController?.navigationBar.setBackgroundImage(UIImage(

我的导航栏是透明的,只有导航栏按钮显示在我的应用程序中。在我的故事板中,我没有标题,所以导航栏看起来什么都没有,但是当我运行模拟器时,我删除的文本在导航栏中

这就是我发现的解决问题的方法:

如果没有透明度,导航栏应该是什么样子

导航条在模拟器中的外观

使条形图透明的代码:

//Makes navigation bar translucent        
self.navigationController?.navigationBar.setBackgroundImage(UIImage(), for: UIBarMetrics.default)
self.navigationController?.navigationBar.shadowImage = UIImage()
self.navigationController?.navigationBar.isTranslucent = true

在您的代码中,内部视图将出现在方法中 使用此代码

self.title = "" // or whatever text you have
在应用程序代理中,是否使用选项方法完成启动:

    UINavigationBar.appearance().barTintColor = .white
    UINavigationBar.appearance().isTranslucent = false

    UINavigationBar.appearance().titleTextAttributes = 
    [NSForegroundColorAttributeName: UIColor.black]  // shouldn't be needed, but if you want something
    UINavigationBar.appearance().tintColor = .blue

从您的故事中删除您所做的任何更改。这可以从代码中完成,也因为它需要在应用程序中保持一致。尝试从代码本身处理状态栏和导航栏。

在代码中,将显示内部视图 使用此代码

self.title = "" // or whatever text you have
在应用程序代理中,是否使用选项方法完成启动:

    UINavigationBar.appearance().barTintColor = .white
    UINavigationBar.appearance().isTranslucent = false

    UINavigationBar.appearance().titleTextAttributes = 
    [NSForegroundColorAttributeName: UIColor.black]  // shouldn't be needed, but if you want something
    UINavigationBar.appearance().tintColor = .blue

从您的故事中删除您所做的任何更改。这可以从代码中完成,也因为它需要在应用程序中保持一致。尝试从代码本身处理状态栏和导航栏。

请检查我的回答请检查我的回答我编辑它的目的。清除并注释我的代码。它没有使导航栏像我想要的那样透明。我编辑了它。清除并注释我的代码。它不能使导航栏像我想要的那样透明。