0
import UIKit

class GoalViewController: UIViewController {

    override func viewDidLoad() {
        super.viewDidLoad()
        navigationController?.navigationBar.prefersLargeTitles = true
        navigationItem.title = "Goal"
        view.backgroundColor = .white
    }

I have ever made Large Titles on this way yet, but now, the VC is completely white, can someone tell me why?

  • `view.backgroundColor = .white` changes the color of the `view`... which is the base view of GoalViewController. It doesn't change the navigation bar color. – aheze Oct 29 '20 at 19:49
  • Does `GoalViewController` have a parent `UINavigationController`? – clawesome Oct 30 '20 at 01:14
  • Like this?:``` let goalVCNavigationController = UINavigationController(rootViewController: GoalViewController()) ``` I have tried everything but nothing worked –  Oct 30 '20 at 05:36

1 Answers1

0

Have you tried this:

navigationItem.largeTitleDisplayMode = .always

You can also use .never for never showing large title or .automatic for inheriting the mode from the previous navigation item

perage
  • 118
  • 1
  • 12
  • I don't get it.... I tried everything but it's not working. Can you show me how you set up the navigationController/bar for the VC. Maybe the way you do it will work –  Oct 30 '20 at 14:23
  • Create a new viewController in storyboard, embed it in a navigation controller and in the navigation item, check "prefers large titles" should alone make it work. But if you navigate back and forth between NC's with small titles, forcing it with .always should work. Does it become large if you drag/scroll the title down? – perage Oct 31 '20 at 08:07
  • I`m not using storyboards, just do it programmatically –  Oct 31 '20 at 15:13