UINavigationBar background color not the exact UIColor I set it to

前端 未结 12 1590
天命终不由人
天命终不由人 2020-12-14 00:16

Please look at the screenshot below.

I set all the tint colors from the same UIColor object for the UINavigationBar, search bar and toolbar at the bottom. But for so

12条回答
  •  陌清茗
    陌清茗 (楼主)
    2020-12-14 00:50

    I had the same problem as the op. After number of hours of failed attempts I decided to change the logic in my code:

    First, set the backround color of the navigation bar:

    navigationBar.barTintColor = UIColor.red
    

    iOS will make the red a bit darker/lighter as described by others in this thread.

    Second, take the color of the navigation bar and set it to what you need, in my case the background of the cell:

    cell.backgroundColor = navigationBar.barTintColor
    

    Now the colors will be the same.

提交回复
热议问题