Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Hide large title when scrolling up

I have a normal view controller that is embedded in a navigation controller. In this view controller, I have a table view that is using the constraints of the safe area. (I don't use a table view controller)

The navigation controller is set to prefer large titles and the mode is set to .always. In beta 2 this worked perfectly, So when I came in the title was large and when I scrolled down it became small (Like the normal one). But since beta 3 this doesn't work anymore.

Anyone know how to turn this back on, or how to make it so when I scroll the table view it will become smaller. Like the behaviour of all the new iOS 11 apps?

Or is this a bug in the current version of swift 4/iOS 11 but the apps like messenger and settings still work this way.

Thanks in advance.

like image 438
Jippe Joosten Avatar asked Jul 17 '17 12:07

Jippe Joosten


2 Answers

I found a workaround on this site basically, if the tableView (or element that has scroll)is not the first view in your view hierarchy, the large title fails to hide automatically.

Example that will NOT workExample that will work

https://markusbodner.com/2017/10/08/fix-large-navigation-bar-title-not-hiding-on-scroll-in-ios-11/

I added on the view willAppear:

if #available(iOS 11.0, *) {
    navigationController?.navigationBar.prefersLargeTitles = true
} else {
    // Fallback on earlier versions
}
like image 137
Sergio Trejo Avatar answered Nov 10 '22 08:11

Sergio Trejo


For me, it was that if you set the boolean "Prefers Large Titles" in the storyboard to true it will stay large, if you turn this on by code it works as expected!

like image 20
Jippe Joosten Avatar answered Nov 10 '22 07:11

Jippe Joosten