滚动条错误地出现在 UICollectionView 部分标题下方 [英] Scrollbar incorrectly appears underneath UICollectionView section header
问题描述
出于某种原因,我的滚动条总是出现在集合视图部分标题下方.任何帮助是极大的赞赏!
For some reason my scrollbar always appears underneath the collection view section header. Any help is greatly appreciated!
推荐答案
我找到了一个解决方法.此问题是集合视图错误地设置了标题视图的 zPosition
.为了解决这个问题,我们将始终确保 zPosition
是我们想要的值.
I found a workaround. This issue is that the zPosition
of the header view is being set by the collection view incorrectly. To fix this, we will always ensure that the zPosition
is our desired value.
创建一个 CALayer
子类,以防止 zPosition
为 0 以外的任何值.
Create a CALayer
subclass which prevents the zPosition
from being anything other than 0.
class CustomLayer: CALayer {
override var zPosition: CGFloat {
get { return 0 }
set {}
}
}
然后将集合视图标题的图层类设置为这个新的子类.
Then set the layer class of your collection view header to this new subclass.
class MyHeaderView: UICollectionReusableView {
// your other custom code here
override class var layerClass: AnyClass {
get { return CustomLayer.self }
}
}
这是一个 iOS 11 错误,因为此问题不会在 iOS 10 中发生.希望在修复错误之前这能正常工作.
This is an iOS 11 bug, as this issue does not occur in iOS 10. Hopefully this works well enough until the bug is fixed.
这篇关于滚动条错误地出现在 UICollectionView 部分标题下方的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!