Smooth scrolling with prefersLargeTitles and UITableView

拟墨画扇 提交于 2019-12-10 17:32:07

问题


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

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.


回答1:


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.



来源:https://stackoverflow.com/questions/46570313/smooth-scrolling-with-preferslargetitles-and-uitableview

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!