UICollectionView 无法遵守 zPosition 和 zIndex - 仅限 iOS 11 [英] UICollectionView fails to honour zPosition and zIndex - iOS 11 only

查看:16
本文介绍了UICollectionView 无法遵守 zPosition 和 zIndex - 仅限 iOS 11的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我试图为这个雷达找到一个解决方法:http://www.openradar.me/34308893

I try to find a workaround for this radar: http://www.openradar.me/34308893

目前在我的 - (void)applyLayoutAttributes:(UICollectionViewLayoutAttributes *)layoutAttributes 我正在执行以下操作:

Currently in my - (void)applyLayoutAttributes:(UICollectionViewLayoutAttributes *)layoutAttributes I'm doing the following:

dispatch_after(dispatch_time(DISPATCH_TIME_NOW, NSEC_PER_MSEC * 50), dispatch_get_main_queue(), ^{
    self.layer.zPosition = 0;
});

但是无论我输入多少 NSEC_PER_MSEC 它都不能正常工作,滚动指示器有时会隐藏在标题后面,尤其是当出现新标题时.还有其他/更好的方法吗?

But no matter how many NSEC_PER_MSEC I enter it doesn't work quite right, the scrolling indicator sometimes hides behind the headers, especially when ne headers appear. Is there another/better approach?

推荐答案

我遇到了类似的问题,UICollectionView 中的标题视图被渲染到另一个视图之上,该视图的 zIndex 设置为 > 0一个自定义的 UICollectionViewFlowLayout.

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.

我的答案是在willDisplaySupplementaryView中设置header view层的zPosition:

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 似乎不支持 UICollectionViewFlowLayout 子类中的 z-index.

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

这篇关于UICollectionView 无法遵守 zPosition 和 zIndex - 仅限 iOS 11的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆