07-19-2023, 01:40 AM
I used dsk1306 solutions, see above. But in my case I had a WebView in the UIViewController with the large title.
So I had to set the UIWebView ScrollView delegate:
self.webView.scrollView.delegate = self
and
extension MyViewController: UIScrollViewDelegate {
func scrollViewWillEndDragging(_ scrollView: UIScrollView, withVelocity velocity: CGPoint, targetContentOffset: UnsafeMutablePointer<CGPoint>) {
if #available(iOS 11.0, *) {
UIView.animate(withDuration: 0.5, animations: {
self.navigationController?.navigationBar.prefersLargeTitles = (velocity.y < 0)
})
}
}
}
So I had to set the UIWebView ScrollView delegate:
self.webView.scrollView.delegate = self
and
extension MyViewController: UIScrollViewDelegate {
func scrollViewWillEndDragging(_ scrollView: UIScrollView, withVelocity velocity: CGPoint, targetContentOffset: UnsafeMutablePointer<CGPoint>) {
if #available(iOS 11.0, *) {
UIView.animate(withDuration: 0.5, animations: {
self.navigationController?.navigationBar.prefersLargeTitles = (velocity.y < 0)
})
}
}
}