我有一个UICollectionView
定期拉动刷新实现,但不知何故,微调器和"拉动刷新"文本显示在集合视图项上方;
如何在物品后面制作?
这是我将UIRefreshControll
添加到UICollectionView
let refreshControl = UIRefreshControl()
refreshControl.attributedTitle = NSAttributedString(string: "Pull down to refresh")
refreshControl.addTarget(self, action: #selector(pullToRefresh), for: UIControlEvents.valueChanged)
collectionView?.refreshControl = refreshControl
答案 0 :(得分:26)
我解决这个问题的方法是将refreshControll
zPosition
改为每个视图后面的内容:
refreshControl.layer.zPosition = -1
希望这可以进一步帮助任何人。
答案 1 :(得分:1)
试试这个:
@IBOutlet weak var collectionView: UICollectionView!
var refresher:UIRefreshControl!
override func viewDidLoad() {
super.viewDidLoad()
let refresher = UIRefreshControl()
self.collectionView!.alwaysBounceVertical = true
self.refresher.tintColor = UIColor.red
self.refresher.addTarget(self, action: #selector(loadData), for: .valueChanged)
self.collectionView!.addSubview(refresher)
}
func loadData() {
//code to execute during refresher
.
.
.
stopRefresher() //Call this to stop refresher
}
func stopRefresher() {
self.refresher.endRefreshing()
}