美文网首页
iOS13,14 CollectionView(2)Inset

iOS13,14 CollectionView(2)Inset

作者: Jacob6666 | 来源:发表于2020-10-15 22:20 被阅读0次

前情提要

在 文章正在审核中... - 简书 文章的基础之上,讨论Apple又给出的两个简单的例子


正文内容

(1) Inset Items Grid

Inset Items Grid

一行代码:

item.contentInsets=NSDirectionalEdgeInsets(top:5, leading:5, bottom:5, trailing:5)

(2) Two-Column Grid

Two-Column Grid

几行代码:

// count: 2 是重点

        let group =NSCollectionLayoutGroup.horizontal(layoutSize: groupSize, subitem: item, count:2)

        let spacing =CGFloat(10)

// interItemSpacing: Supplies additional spacing between items along the layout axis of the group

        group.interItemSpacing= .fixed(spacing)

        let section =NSCollectionLayoutSection(group: group)

        section.interGroupSpacing= spacing

// leading,trailing 首尾间距

        section.contentInsets=NSDirectionalEdgeInsets(top:0, leading:10, bottom:0, trailing:10)

相关文章

网友评论

      本文标题:iOS13,14 CollectionView(2)Inset

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