UIRefreshControl出现在集合视图项的顶部而不是后面

Iva*_*ino 8 ios uicollectionview uirefreshcontrol swift3

我有一个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
Run Code Online (Sandbox Code Playgroud)

Iva*_*ino 29

我想出来的方法是refreshControll zPosition使用以下内容将每个视图改为后面:

refreshControl.layer.zPosition = -1
Run Code Online (Sandbox Code Playgroud)

希望这对任何人都有帮助.

  • 注意:当前修复不能在滚动期间修复table(collection)View的标题视图的位置。标题视图在刷新控件的高度上垂直移动。使用setRefreshControl而不是addSubview。适用于> = iOS 10 (2认同)