
[英]Refresh Controller doesn't appears after setting backgroundView in CollectionView
[英]Is it possible to put a Refresh Controller in the Header of CollectionView?
我有一个带有Header
的CollectionView
,我想将RefreshController
添加到我已经做过的CollectionView
中。 正如我所期望的那样,它显示在Header
上方。 但是我希望RefreshController
显示在Header
中。
原因是Toolbar
覆盖了 Header。 当我下拉刷新时, Header
以我希望RefreshController
可见的方式可见。 但是我必须拉低Header
的高度才能使RefreshController
可见,即
a) 滚动距离过大和
b) RefreshController
和CollectionView
之间的空间太大
这是一些代码:
var refreshControl = UIRefreshControl()
override func viewDidLoad() {
super.viewDidLoad()
[...]
refreshControl.tintColor = .gray
refreshControl.backgroundColor = .white
refreshControl.addTarget(self, action: #selector(refreshContents), for: .valueChanged)
eventCollectionView.refreshControl = refreshControl
eventCollectionView.register(EventHeaderView.self, forSupplementaryViewOfKind: UICollectionView.elementKindSectionHeader, withReuseIdentifier: toolbarId)
}
@objc func refreshContents() {
self.perform(#selector(finishedRefreshing), with: nil, afterDelay: 1.5)
}
@objc func finishedRefreshing() {
refreshControl.endRefreshing()
}
func collectionView(_ collectionView: UICollectionView, layout collectionViewLayout: UICollectionViewLayout, referenceSizeForHeaderInSection section: Int) -> CGSize {
return .init(width: screenWidth, height: 50)
}
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.