'How to make my UICollectionView's scroll to bottom and unhide top and bottom bars more elegant?
The Apple News app has a clean and smooth "unhiding" of the navigation bar and bottom toolbar when you scroll to the bottom of the page. I am trying to mimic this "unhiding" of the top and bottom bars, but having trouble making it look smooth.
My navigation bar and toolbar are managed by the nav controller, and the collection view is instantiated programmatically, with property collectionView.alwaysBounceVertical = true and collectionView.contentInsetAdjustmentBehavior = .automatic
It is also constrained to the parent ViewController like so:
constrain(collectionView, view) {
$0.left == $1.left
$0.right == $1.right
$0.bottom == $1.bottom
$0.top == $1.topMargin
}
Here is a visual representation of what each instance looks like:
My App's scroll to bottom:
Apple News scroll to bottom:
I am using the following code to catch when scrolling to bottom occurs, and then animate the unhiding of the toolbars.
extension MagPageViewController: UICollectionViewDelegate {
func scrollViewDidEndDecelerating(_ scrollView: UIScrollView) {
let contentOffsetY = scrollView.contentOffset.y
if contentOffsetY >= (scrollView.contentSize.height - scrollView.bounds.height) {
if let parent = pageboyParent as? MagReadingViewController {
UIView.animate(withDuration: 0.25, delay: 0, options: .allowAnimatedContent) {
parent.navigationController?.setToolbarHidden(false, animated: true)
parent.navigationController?.setNavigationBarHidden(false, animated: true)
}
}
}
}
}
What can I do to make my app's scroll to bottom and subsequently unhiding bars look like Apple New's?
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|


