简体   繁体   中英

Navigation Bar Title background is white in iOS11

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.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM