问题
The navigation bar has a .isTranslucent property that gives it that gray background color
navigationController?.navigationBar.isTranslucent = true
I want my entire view controller to match that same exact color and .lightGray isn't it. I tried playing with the view controller's view's .alpha and .isOpaque properties but I cannot get it to match.
Does anyone know the rgb colors or another way I can get my view controller's view's background color to match that same translucent gray color?
override func viewDidLoad() {
    super.viewDidLoad()
    // I tried playing with different combinations of all of these in different ways
    view.backgroundColor = .lightGray
    view.alpha = .5
    view.isOpaque = false
} 
回答1:
This would set the view and navigation bar to the same colour:
view.backgroundColor = UIColor(red   : 249.0/255.0,
                               green : 249.0/255.0,
                               blue  : 249.0/255.0,
                               alpha : 1.0)
The seam would still be there. If you'd like to remove it :
navigationController?.navigationBar.shadowImage = UIImage()
来源:https://stackoverflow.com/questions/55079945/what-are-the-rgb-equivalent-colors-to-the-navigation-bars-istranslucent-color