Swift51.com
Swift 头像
Swift  2018-03-28 11:12

轻松处理UICollectionView流式布局的框架Blueprints

回复:0  查看:5245  感兴趣:106  赞:4  
轻松处理UICollectionView流式布局的框架Blueprints,它配备了两个内置布局Vertical layout和Horizontal layout。

Vertical layout示例代码:
let blueprintLayout = VerticalBlueprintLayout(
  itemsPerRow: 1.0,
  itemSize: CGSize(width: 200, height: 60),
  minimumInteritemSpacing: 10,
  minimumLineSpacing: 10,
  sectionInset: EdgeInsets(top: 10, left: 10, bottom: 10, right: 10),
  stickyHeaders: true,
  stickyFooters: false
)
let collectionView = UICollectionView(frame: .zero,
                                      collectionViewLayout: blueprintLayout)

Horizontal layout示例代码:
let blueprintLayout = HorizontalBlueprintLayout(
  itemsPerRow: 1.0,
  itemsPerColumn: 2,
  itemSize: CGSize(width: 200, height: 200),
  minimumInteritemSpacing: 10,
  minimumLineSpacing: 10,
  sectionInset: EdgeInsets(top: 10, left: 10, bottom: 10, right: 10),
  stickyHeaders: true,
  stickyFooters: true
)
let collectionView = UICollectionView(frame: .zero,
                                      collectionViewLayout: blueprintLayout)

相关开源代码