UICollectionView fails to honour zPosition and zIndex - iOS 11 only

☆樱花仙子☆ 提交于 2019-12-01 18:04:07
user2921854

I had a similar problem where a header view in a UICollectionView was getting rendered above another view that had it's zIndex set > 0 in a custom UICollectionViewFlowLayout.

The answer for me was to set the header view layer's zPosition in willDisplaySupplementaryView:

override public func collectionView(_ collectionView: UICollectionView,
                                    willDisplaySupplementaryView view: UICollectionReusableView,
                                    forElementKind elementKind: String,
                                    at indexPath: IndexPath) {
    if elementKind == UICollectionView.elementKindSectionHeader && type(of: view) == CollectionViewSectionHeaderView.self {
      view.layer.zPosition = -1
    }
  }

iOS11 doesn't seem to honor z-indexes in UICollectionViewFlowLayout subclasses.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!