【问题标题】:Going to next view changes the navigation bar background color转到下一个视图会更改导航栏背景颜色
【发布时间】:2017-11-22 07:38:17
【问题描述】:

当我使用 push 方法呈现新视图时,我的导航栏颜色的一小部分会在一段时间内发生变化,因为它在该部分显示为深蓝色,然后又恢复为浅色。

如图所示。

我应该如何解决这个问题

【问题讨论】:

    标签: ios uiviewcontroller storyboard uinavigationbar


    【解决方案1】:

    你可以在appdelegate中设置

    func application(application: UIApplication, didFinishLaunchingWithOptions launchOptions: [NSObject: AnyObject]?) -> Bool {
        // Override point for customization after application launch.
        UINavigationBar.appearance().barTintColor = UIColor(red: 0, green: 0/255, blue: 205/255, alpha: 1)
        UINavigationBar.appearance().tintColor = UIColor.whiteColor()
        UINavigationBar.appearance().titleTextAttributes = [NSForegroundColorAttributeName:UIColor.whiteColor()]
    
        return true
    }
    

    或者可以在viewcontroller中设置

    override func viewWillAppear(animated: Bool) {
    super.viewWillAppear(animated)
    self.navigationController?.navigationBar.barTintColor = UIColor.whiteColor()
    self.navigationController?.navigationBar.tintColor = UIColor.blueColor()
    self.navigationController!.navigationBar.titleTextAttributes = [NSForegroundColorAttributeName: UIColor.blueColor()]
    
    }
    

    更多细节和信用:Swift - iOS : Change the color of a Navigation Bar

    希望有帮助

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2014-07-30
      • 2017-04-30
      • 1970-01-01
      • 2018-01-05
      • 1970-01-01
      相关资源
      最近更新 更多