0

enter image description here

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
} 
Lance Samaria
  • 17,576
  • 18
  • 108
  • 256

1 Answers1

0

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)

cap

The seam would still be there. If you'd like to remove it :

navigationController?.navigationBar.shadowImage = UIImage()
ielyamani
  • 17,807
  • 10
  • 55
  • 90
  • 1
    I was using that to remove the shadow image but making it reappear in another vc when pushing or popping was a headache because the navigation bar blinked when reappearing. I used this instead https://stackoverflow.com/a/55080068/4833705 – Lance Samaria Mar 09 '19 at 18:00
  • Might be easier to do: `view.backgroundColor = UIColor(white: 249.0/255.0, alpha: 1.0)` – rmaddy Mar 09 '19 at 18:24
  • @rmaddy: Good alternative – ielyamani Mar 09 '19 at 18:25