Custom layout for a collection view using vertical scrolling with float cell, like UICollectionViewFlowLayout. Written in Swift.
iOS 9 above, you can just set sectionHeadersPinToVisibleBounds = true
Swift 3.0, iOS 8.0
Just set layout properties when viewDidLoad
import GWCollectionViewFloatCellLayout
override func viewDidLoad() {
super.viewDidLoad()
let sectionWidth = UIScreen.main.bounds.width
self.layout.floatItemSize = CGSize(width: sectionWidth, height: 20)
self.layout.itemSize = CGSize(width: sectionWidth / 6, height: 40)
self.layout.headerReferenceSize = CGSize(width: sectionWidth, height: 50)
self.layout.footerReferenceSize = CGSize(width: sectionWidth, height: 50)
self.layout.sectionInset = UIEdgeInsets(top: 10, left: 20, bottom: 30, right: 40)
self.layout.minimumLineSpacing = 2
self.layout.minimumInteritemSpacing = 4
}
Feel free to drag GWCollectionViewFloatCellLayout.swift
to your iOS Project. But it's recommended to use Carthage (or CocoaPods).
github "gewill/GWCollectionViewFloatCellLayout" >= 1.0.0
pod 'GWCollectionViewFloatCellLayout', '~> 1.0.0'
Thanks to Brightec blog & Demo
Follow and contact me on Twitter or Sina Weibo. If you find an issue, just open a ticket on it. Pull requests are warmly welcome as well.
GWCollectionViewFloatCellLayout is available under the MIT License