解决办法为自定义一个CALayer,把zPosition设置为0
class CustomLayer: CALayer {
override var zPosition: CGFloat {
get { return 0 }
set {}
}
}
然后在自己的HeaderView中调用一下
class YourHeaderView: UICollectionReusableView {
override class var layerClass: AnyClass {
get { return CustomLayer.self }
}
}