Section Headers in UITableView when inset of tableview is changed

前端 未结 4 2014
刺人心
刺人心 2021-02-01 07:18

I have implemented a \"Pull to refresh\" in my tableView like the iPhone app Twitter or Facebook.
My tableView has sections with head views. When the tableView is in \"Refre

4条回答
  •  挽巷
    挽巷 (楼主)
    2021-02-01 07:47

    Looks like an UIKit bug. Found a workaround:

    // your initial inset
    let kInset = 40.0
    
    func scrollViewDidScroll(_ scrollView: UIScrollView) {
        let offset = scrollView.contentOffset.y
        if (offset < 0) {
            scrollView.contentInset = UIEdgeInsets(top: kInset, left: 0.0, bottom: 0.0, right: 0.0)
        } else {
            scrollView.contentInset = .zero
        }
    }
    

提交回复
热议问题