简体   繁体   中英

NavigationBar prefersLargeTitle not working

Using iOS 13.3,

I observe a strange behaviour of the navigationBar. If dragging up, the navigationBar contracts. (see video)

Don't worry about the tabs that are part of the navigationBar. The strange behaviour also happens without them. And also the fact that the ViewController presents in a modal sheet is irrelevant - the strange contraction behaviour also happens in a classic view. So far, I only knew this contracting behaviour from a SearchBar. But no such is present here.

How can I always keep the navigationBar at a fixed large size ?

在此处输入图片说明

I tried without success....

navigationController?.navigationBar.prefersLargeTitles = true
navigationItem.largeTitleDisplayMode = .always

I finally found the solution:

Since there was a tableView in the screen, the following was needed to prevent the contracting of the navigationBar:

tableView.isScrollEnabled = false

If your navigationBar has a custom height or for other reasons, you can also set the tableView's Insets to place it downwards like this:

tableView.contentInset = UIEdgeInsets(top: 90.0, left: 0.0, bottom: 0.0, right: 0.0)

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