在iOS 11下 UICollectionView 滾動(dòng)條被 SectionHeaderView 遮擋,如下圖所示:

效果圖
解決方案:
創(chuàng)建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
或者寫一個(gè)繼承UICollectionReusableView的公共類,在此類中添加以上代碼!
git地址
參考:
stackoverflow
