在iOS 11下 UICollectionView 滚动条被 SectionHeaderView 遮挡,如下图所示:
![](https://img.haomeiwen.com/i1242012/d6fb0271782b52d8.png)
解决方案:
创建YDCustomLayer继承CALayer
- YDCustomLayer.h
#ifdef __IPHONE_11_0
@interface YDCustomLayer : CALayer
@end
#endif
- YDCustomLayer.m
#ifdef __IPHONE_11_0
@implementation YDCustomLayer
- (CGFloat) zPosition {
return 0;
}
@end
#endif
- 在自定义的UICollectionReusableView的文件中增加下面的代码,就可以解决了
#ifdef __IPHONE_11_0
+ (Class)layerClass {
return [YDCustomLayer class];
}
#endif
或者写一个继承UICollectionReusableView的公共类,在此类中添加以上代码!
git地址
参考:
stackoverflow
网友评论