For some reason in iOS 11 the title label in navigation bar has a white background:
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?
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
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)
]
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.