【问题标题】:UIRefreshControl block views below下面的 UIRefreshControl 块视图
【发布时间】:2021-04-29 17:48:09
【问题描述】:

我是 IOS 编程的新手。我参与了一个现有的项目,我面临一个问题。 UIRefreshControl 正在阻止下面的视图。像附加的图像(UIRefreshControl 是透明的黑色)。

UIRefreshControl 正在阻止其下方的视图。但是当我做一些小滚动时,UIRefreshControl 消失了,然后下面的按钮就可以点击了。

这里是一些sn-p的代码。 CommentView.swift

     lazy var collectionView: UICollectionView = {
        layout.scrollDirection = .vertical
        let collectionView: UICollectionView = UICollectionView(frame: .zero, collectionViewLayout: layout)
        collectionView.translatesAutoresizingMaskIntoConstraints = false
        collectionView.isUserInteractionEnabled = true
        collectionView.backgroundColor = .white
        collectionView.refreshControl = refreshControl
        collectionView.registerCustomCell(CommentCell.self)
        collectionView.register(CommentHeaderView.self, forSupplementaryViewOfKind: CommentView.className, withReuseIdentifier: CommentHeaderView.className)
        return collectionView
    }()
    
    lazy var refreshControl: UIRefreshControl = {
        let refresh = UIRefreshControl()
        refresh.tintColor = .primary
        refresh.addTarget(self, action: #selector(handleRefresh), for: .valueChanged)
        refresh.backgroundColor = UIColor.blackTransparent
        return refresh
    }()

被阻止的视图在 CommentHeaderView.swift 中声明。

编辑 我试过了

refresh.layer.zPosition = -100

但仍然无法正常工作。

有人可以帮助我吗?提前致谢!

【问题讨论】:

    标签: ios swift swiftui


    【解决方案1】:

    我尝试了下面的解决方案,效果很好。

    refreshControl.layer.zPosition = -1;
    refreshControl.userInteractionEnabled = NO;
    

    UIRefreshController goes over the UICollectionView

    谢谢大家!

    【讨论】:

      猜你喜欢
      • 2017-05-10
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2013-08-09
      • 1970-01-01
      • 2013-06-16
      • 1970-01-01
      • 2012-02-29
      相关资源
      最近更新 更多