Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Smooth scrolling with prefersLargeTitles and UITableView

I encountered a problem with the scrolling when using the prefersLargeTitles and added UITableView.

If I set the prefersLargeTitles within a navigation controller and its root is a UITableViewController everything is fine, scrolling of the navigation large title works the same way we can see in the system apps (in iOS 11+).

The problem

enter image description here

However, if I use a UIViewController and add a UITableView in it, scroll seems to act differently. Navigation bar is moving more/faster than I actually scroll. It just hides/shows the large title whenever I scroll into a position that just triggers it, so I end up with the totally different feeling.

like image 245
Jakub Truhlář Avatar asked Oct 04 '17 16:10

Jakub Truhlář


1 Answers

Turns out that the layout is causing this problem.

The problem occurs if the UITableView use Align top to: Safe Area constraint (besides the bottom, leading and trailing to Safe Area) and is not extended under the bar.

However if I use the extended layout, align top to the superview, I can still use the UITableView and get the correct behaviour of the large title and its navigation bar.

edgesForExtendedLayout = .top
extendedLayoutIncludesOpaqueBars = true

Or use navigation bar's isTranslucent = true which extends it too.

like image 198
Jakub Truhlář Avatar answered Nov 19 '22 10:11

Jakub Truhlář