简体   繁体   中英

how to get largeTitle on current vc, but small title on vc being pushed to?

I have a simple "more" screen where I want to have a largeTitle . I have several entries in a static table view which are leading to other view controllers. I want to have the large title in the "more" screen, but not in the screens pushed to. Either are all of the titles large or all small. How do I do it? I am using the storyboard.

在此处输入图片说明

Did you try to set

self.navigationController?.navigationBar.prefersLargeTitles = false

in your second View Controller?

On the detail vc set the following:

self.navigationItem.largeTitleDisplayMode = .never

If you access the navigationItem of the navigationController , it will change all detail vc, but if you access the navigationItem of the detailVC, it will only change the current title in the navigationBar .

You cannot do that in Storyboard, because you cannot click on the navigationBar itself in the detail vc.

More information available in a WWDC video from 2017 .

Because there is only one navigation controller which stacks all your views, you can try to write

self.navigationController?.navigationBar.prefersLargeTitles = false

in the viewWillApear method of the second viewController and on viewWillDisappear you can change it again to

self.navigationController?.navigationBar.prefersLargeTitles = true

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