Navigation Bar Title background is white in iOS11

Viewed 1679

For some reason in iOS 11 the title label in navigation bar has a white background:

navigation bar with white background for title

This is just a normal navigation controller and the title is being set the default way:

self.title = @"My Title";

This problem is only happening in iOS 11 and the screenshot was taken from the simulator, otherwise for previous iOS version this works fine.

Any suggestions as to how i can have a normal clear background label or remove the white background which is coming up for whatever reason?

1 Answers

Check if you have set the title text attributes correctly. You can set the title text attributes from the Storyboard or Programatically. Select Storyboard -> NavigationBar -> Go to attribute inspector -> Title Text Attributes

enter image description here

or in ViewController try setting it manually

Swift 4:

         self.navigationController?.navigationBar.titleTextAttributes = [
            NSAttributedStringKey.foregroundColor: UIColor.white,
            NSAttributedStringKey.font: UIFont.systemFont(ofSize: 17, weight: .bold)
        ]

Swift 3:

        self.navigationController?.navigationBar.titleTextAttributes = [
            NSForegroundColorAttributeName: UIColor.white,
            NSFontAttributeName: UIFont.systemFont(ofSize: 17, weight: .bold)
        ]
Related