I have got a View Controller embedded in a Navigation Controller with prefers large titles option set to true; inside the View Controller there’s a Scroll View.
I want to make the nav bar shrink when scrolling.
How could I achieve this?
Xcode 9, Swift 4, iOS 11
The scrollable content top constraint must align to the top of the view controller’s view. The scrollable content (or its container) must be the first subview in the view controller’s z-axis. If you are using a UIRefreshControl, make sure to use the standard way to assign it to the scrollable content.
If the tableView is not the first view, the large title fails to hide automatically. You most likely need to make sure your tableView is the first element in the main view’s subviews array. I hope that this solves your problem.
If you are using a UIRefreshControl, make sure to use the standard way to assign it to the scrollable content. Lastly, if the screen that you create is not complicated, you can always use the UITableViewController and UICollectionViewController to avoid any of these glitches.
If you are using the large title navigation bar, most probably you will want to adjust its styling to suit your needs. This is where the UINavigationBarAppearance APIs introduced in iOS 13 comes in handy. For example, you can use the following code snippet to customize a specific view controller’s navigation bar font and background color.
I have not achieved this using a UIScrollView but I achieved it with other ViewControllers using a UITableView as first view.
If the tableView is not the first view, the large title fails to hide automatically. You most likely need to make sure your tableView is the first element in the main view’s subviews array.
I hope that this solves your problem.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With