1

I was messing around on the IB on Xcode, and I some how got a fade on the navigation bar (take a look here). The color is whiter/lighter on the top part of the navigation bar and gets darker until the bottom of the navigation bar. I don't know how to return it back to a "solid" color (i.e. remove the gradient).

Anyone know how to accomplish this?

hvasam
  • 304
  • 4
  • 12

1 Answers1

1

There are several ways. I don't know if this issue exists when you run the project so I will cover all the bases.

Here are some suggesstions:

  1. Delete the Navigation Controller and embed your View Controller in a new Navigtaion Controller. The easiest way is to select your View Controller, go to the top navigation where you can see File, Edit, View, etc. and select Editor -> Embed In -> Navigation Controller.

Image walkthrough

  1. In your viewDidLoad() you can set the colour of your navigation controller like so:

navigationController?.navigationBar.barTintColor = UIColor.blue

  1. In your story board, you can select the Navigation Controller scene and select the Navigation Bar and play around there, however the above 2 would be preferred. enter image description here

  2. If you want the gradient at run time, see this answer: https://stackoverflow.com/a/43637829/4008175

I am making the assumption that you have not created a custom navigation bar class with an @IBDesignable element. I also have a feeling that when you run the project, the gradient won't be present, but since that is not mentioned, I would be ok if I am wrong.

See how these solutions work for you.

App Dev Guy
  • 5,396
  • 4
  • 31
  • 54
  • 1
    The gradient does appear in the IB and the project simulator (when built/run). So, I tried suggestion 1, and it still gave me a gradient on the navigation bar (which is very strange - it seems like it's the default behaviour). However, suggestion 2 worked for me. Thanks! – hvasam May 25 '17 at 02:21