Shrink large title when scrolling (not UITableViewController) iOS 11

前端 未结 12 1710
太阳男子
太阳男子 2020-12-10 02:35

I have got a View Controller embedded in a Navigation Controller with prefers large titles option set to true; inside the View Controller there’s a Scroll View.

I wa

12条回答
  •  轻奢々
    轻奢々 (楼主)
    2020-12-10 03:09

    I've used something that is similar to Kamil Szostakowski's answer for view with UICollectionView.

    func scrollViewWillEndDragging(_ scrollView: UIScrollView, withVelocity velocity: CGPoint, targetContentOffset: UnsafeMutablePointer) {
        UIView.animate(withDuration: 0.5, animations: {
            self.navigationController?.navigationBar.prefersLargeTitles = (velocity.y < 0)
        })
    }
    

    It may be not so smooth but I haven't found better option yet.

提交回复
热议问题