Shrink large title when scrolling (not UITableViewController) iOS 11

前端 未结 12 1745
太阳男子
太阳男子 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 02:53

    If u have problem collapse root navigationBar from presented VC's scrollView, can try this: Add UIScrollView to RootVC. Important - UIScrollView must be root view(at index 0). In presentedVC we can use scrollViewDidScroll and set offset on our root UIScrollView. see here with gif and code RootVC view hierarchy: screenshot (sorry for link, not enough reputation)

    in presentedVC try this

    func scrollViewDidScroll(_ scrollView: UIScrollView) {
            if #available(iOS 11.0, *) {
                let offset = scrollView.contentOffset
                rootVC.scrollView.contentOffset = offset
            }
    }
    

提交回复
热议问题