1

Before iOS 11, to make a custom label, I just did this:

let titleLabel = UILabel(frame: CGRect(x: 0, y: 0, width: UIScreen.main.bounds.size.width, height: 40))
titleLabel.text = self.customTitleText
titleLabel.backgroundColor = .clear
titleLabel.textAlignment = .left
titleLabel.textColor = .white
titleLabel.font = UIFont.boldSystemFont(ofSize: 17)
titleLabel.adjustsFontSizeToFitWidth = true
titleLabel.minimumScaleFactor = 0.25
navigationItem.titleView = titleLabel

Now, the titleView doesn't seem to affect the large title. What can I do to achieve a text shrink in iOS 11?

Minebomber
  • 1,209
  • 2
  • 12
  • 35

1 Answers1

0

You can use like this :

self.navigationController?.navigationBar.prefersLargeTitles = true
self.navigationController?.navigationBar.largeTitleTextAttributes = [
        NSAttributedStringKey.foregroundColor: UIColor.red,
        NSAttributedStringKey.font: UIFont.boldSystemFont(ofSize: 17)
    ]
Vini App
  • 7,339
  • 2
  • 26
  • 43