1

我对 UINavigationBar 样式有疑问:

1)我在 AppDelegate.swift 中应用了样式更改:

    //Change Navigation bar appearance
    UINavigationBar.appearance().barTintColor = UIColor (red: 231.0/255.0, green: 95.0/255.0, blue: 53.0/255.0, alpha: 0.3)
    UINavigationBar.appearance().tintColor = UIColor.whiteColor()

    if let barFont = UIFont (name: "AvenirNextCondensed-DemiBold", size: 22.0){
        UINavigationBar.appearance().titleTextAttributes = [NSFontAttributeName: barFont, NSForegroundColorAttributeName: UIColor.whiteColor()]   
    }

    //Status bar text change to white
    UIApplication.sharedApplication().statusBarStyle = .LightContent

    //Toolbar Buttons color change
    UIBarButtonItem.appearance().tintColor = UIColor(red: 235.0/255.0, green: 73.0/255.0, blue: 27.0/255.0, alpha: 1.0)
    UIToolbar.appearance().barTintColor = UIColor(red: 237.0/255.0, green: 240.0/255.0, blue: 243.0/255.0, alpha: 0.5)

2)我启动应用程序并在同一个导航控制器中使用 push segue 从主视图转到连接的视图(如果我使用模态 segue,则不会出现此问题)并展开到第一个视图

3)导航栏失去了标题和样式,状态栏也失去了改变的风格。虽然如果我在 ViewWillAppear 中再次更改它(样式和标题) - 它工作正常。

问题是:这是否应该像那样工作并且必须在每个 ViewWillAppear 中重新加载样式,还是我做错了什么?

提前致谢!迈克尔

4

0 回答 0