前情提要
在 文章正在审核中... - 简书 文章的基础之上,讨论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)
网友评论