Navigation bar becomes white when a UISearchController is added to it

前端 未结 4 758
感情败类
感情败类 2020-12-14 23:50

When I add a UISearchController to a UINavigationItem from an UINavigationController; it becomes white when the view loads and changes to the color specified when the user c

4条回答
  •  一个人的身影
    2020-12-15 00:03

    I'm experiencing same issue, and already opened a radar to Apple. Even though, if you set the backgroundColor to the appearance of the UINavigationBar, then the navigation bar instead of becoming transparent when pulling down and showing the search bar becomes that color, but then the status bar still remains white.

    UINavigationBar.appearance().tintColor = .white
    UINavigationBar.appearance().barTintColor = .blue
    UINavigationBar.appearance().titleTextAttributes = [NSAttributedString.Key.foregroundColor : UIColor.white]
    UINavigationBar.appearance().backgroundColor = .red
    

    Here is some code that tries to mitigate that behaviour, but I'm open to hear for the status bar thing

提交回复
热议问题