美文网首页
iOS 11 下 UICollectionView 滚动条被 S

iOS 11 下 UICollectionView 滚动条被 S

作者: 看我的大白眼 | 来源:发表于2017-12-12 14:18 被阅读40次

在iOS 11下 UICollectionView 滚动条被 SectionHeaderView 遮挡,如下图所示:

效果图

解决方案:
创建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地址

YDBaseCollectionReusableView

参考:

stackoverflow

stackoverflow

相关文章

网友评论

      本文标题:iOS 11 下 UICollectionView 滚动条被 S

      本文链接:https://www.haomeiwen.com/subject/ozwgixtx.html