0

I have a blueView that i want to cover the large title area (Fav10) within the navigation bar. But I have trouble accessing it. Setting the navBar's topItem.titleView to my blueView just gives me 2 titles. How do I go about customizing this area?

enter image description here

 override func viewDidLoad() {
    super.viewDidLoad()
    setupNavBar()
}

private func setupNavBar() {
    navigationItem.title = "Fav 10"
    let blueView = UIView()
    blueView.backgroundColor = .blue
    blueView.frame.size = CGSize(width: 40, height: 40)

    navigationController?.navigationBar.isTranslucent = false
    navigationController?.navigationBar.topItem!.titleView = blueView
    navigationController?.navigationBar.prefersLargeTitles = true
}
Kenny Ho
  • 409
  • 3
  • 16
  • Possible duplicate of [Customize navigation bar with title view](https://stackoverflow.com/questions/8433016/customize-navigation-bar-with-title-view) – koen Apr 25 '19 at 16:26
  • That doesn't work. – Kenny Ho Apr 25 '19 at 20:46
  • Please explain *what* doesn't work. – koen Apr 25 '19 at 22:57
  • setting the navigationItem.title = view doesn't work. That's the solution that you gave. I've tried that before as well – Kenny Ho Apr 25 '19 at 23:50
  • Have you tried setting the color of the navigationBar? See eg here: https://stackoverflow.com/questions/24687238/changing-navigation-bar-color-in-swift – koen Apr 26 '19 at 12:07
  • im not trying to change the nav bar color. I just did a blueView to test to see if it worked. I just want to be able to cover the large navigation title area. Not where the Settings and Add area is, just the large title area. – Kenny Ho Apr 26 '19 at 13:26

0 Answers0