iOS中UICollectionView设置cell大小以及间距

今天突然用到了UICollectionView,但发现忘记怎么设置cell的大小了于是查了一下资料,又重新温习了一下这方面的内容。代码如下

let layout = UICollectionViewFlowLayout()
layout.scrollDirection = .horizontal //设置滚动方向
layout.itemSize = CGSize(width: 100, height: 100)//设置cell的大小
layout.sectionInset = UIEdgeInsets.zero//设置分组的间距
layout.minimumLineSpacing = 0 //设置最小行间距
layout.minimumInteritemSpacing = 10//设置小列间距
self.mCollectionView.collectionViewLayout = layout //最后将layout赋值给UICollectionView
0 0 vote
Article Rating
Subscribe
提醒
guest
1 评论
Oldest
Newest Most Voted
Inline Feedbacks
View all comments
1
0
Would love your thoughts, please comment.x
()
x