kingjiajie / JJCollectionViewRoundFlowLayout_Swift

JJCollectionViewRoundFlowLayout_Swift是JJCollectionViewRoundFlowLayout(OC:https://github.com/kingjiajie/JJCollectionViewRoundFlowLayout )的Swift版本,JJCollectionViewRoundFlowLayout可设置CollectionView的BackgroundColor,可根据用户Cell个数计算背景图尺寸,可自定义是否包括计算CollectionViewHeaderView、CollectionViewFootererView或只计算Cells。设置简单,可自定义背景颜色偏移,设置显示方向(竖向、横向)显示,不同Section设置不同的背景颜色,设置Cell的对齐方式,支持左对齐,右对齐,居中。
MIT License
73 stars 13 forks source link

sectionInset 设置左右间距会相互抵消 #5

Closed CoderLGL closed 3 years ago

CoderLGL commented 3 years ago

layout.sectionInset = UIEdgeInsets.init(top: 20, left: 20, bottom: 20, right: 20);

left: 20 和 right: 20 相互抵消,不再起作用

OC的好像没问题,swift会出现这种现象

kingjiajie commented 3 years ago

layout.sectionInset = UIEdgeInsets.init(top: 20, left: 20, bottom: 20, right: 20);

left: 20 和 right: 20 相互抵消,不再起作用

OC的好像没问题,swift会出现这种现象

您好,请问你这边设置的时候是横向还是竖向的? left: 20 和 right: 20 相互抵消,这个效果是是怎么样的呢? 有没有图或者更多的描述参考一下? 意思是left: 20 和 right: 20的时候,left设置了的20就没了的意思吗? 如果是这样的话,因为我这边会对layout.sectionInset偏移进行回补,既底色view会在0,0处开始显示,在broder的Inset设置20,底色就会偏移20了。

CoderLGL commented 3 years ago

我是修改的demo: NextViewController 里面的 sectionInset和 itemSize layout.sectionInset = UIEdgeInsets.init(top: 20, left: 120, bottom: 20, right: 80); layout.itemSize = CGSize.init(width: UIScreen.main.bounds.size.width - 200, height: 100)

我又测了一下,找到了解决办法: itemSize的宽度必须减去 sectionInset 左右加起来的的距离 比如: left: 120, right: 80 那么itemSize宽度必须是 UIScreen.main.bounds.size.width - 200

kingjiajie commented 3 years ago

我是修改的demo: NextViewController 里面的 sectionInset和 itemSize layout.sectionInset = UIEdgeInsets.init(top: 20, left: 120, bottom: 20, right: 80); layout.itemSize = CGSize.init(width: UIScreen.main.bounds.size.width - 200, height: 100)

我又测了一下,找到了解决办法: itemSize的宽度必须减去 sectionInset 左右加起来的的距离 比如: left: 120, right: 80 那么itemSize宽度必须是 UIScreen.main.bounds.size.width - 200

你好,我按照你这边的设置进行了尝试,暂时不清楚你这边提到的问题是什么情况,是cell穿出去了背景view么?

如果是说因为Cell的size大小比较大,然后选择竖向显示,设置了left: 120, right: 80, 当cell的width超出了collectionview的width-sectioninsert的left和right,就会出现left设置的120 最终显示的没有120的情况,这个是系统对cell的处理,因为系统处理的逻辑好像就是这样的。

当使用的是UICollectionViewFlowLayout也一样出现该情况的

CoderLGL commented 3 years ago

是的系统逻辑就是这样的,项目没问题

------------------ 原始邮件 ------------------ 发件人: "kingjiajie/JJCollectionViewRoundFlowLayout_Swift" @.>; 发送时间: 2021年8月7日(星期六) 下午4:28 @.>; @.**@.>; 主题: Re: [kingjiajie/JJCollectionViewRoundFlowLayout_Swift] sectionInset 设置左右间距会相互抵消 (#5)

我是修改的demo: NextViewController 里面的 sectionInset和 itemSize layout.sectionInset = UIEdgeInsets.init(top: 20, left: 120, bottom: 20, right: 80); layout.itemSize = CGSize.init(width: UIScreen.main.bounds.size.width - 200, height: 100)

我又测了一下,找到了解决办法: itemSize的宽度必须减去 sectionInset 左右加起来的的距离 比如: left: 120, right: 80 那么itemSize宽度必须是 UIScreen.main.bounds.size.width - 200

你好,我按照你这边的设置进行了尝试,暂时不清楚你这边提到的问题是什么情况,是cell穿出去了背景view么?

如果是说因为Cell的size大小比较大,然后选择竖向显示,设置了left: 120, right: 80, 当cell的width超出了collectionview的width-sectioninsert的left和right,就会出现left设置的120 最终显示的没有120的情况,这个是系统对cell的处理,因为系统处理的逻辑好像就是这样的。

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub, or unsubscribe. Triage notifications on the go with GitHub Mobile for iOS or Android.