I would like to implement it so that, like the iPhone’s default music app, it is shown as a large title at first and when you scroll up, it is shown as a small title. So I implemented it as below, but it is not smooth and hard like the music app. I tried animation, but it is not the same.
How should I implement it?
func scrollViewDidScroll(_ scrollView: UIScrollView) {
if scrollView.contentOffset.y > 0 {
UIView.animate(withDuration: 0.3) {
self.navigationController?.navigationBar.prefersLargeTitles = false
}
} else {
UIView.animate(withDuration: 0.3) {
self.navigationController?.navigationBar.prefersLargeTitles = true
}
}
}
1