Talk on subclassing UICollectionViewLayout to play with different layout effect and animations using demo app ,'Croupier'. This presentation was held on Munich iOS Meetup 2015/12/02 at Stylight.
(0..<self.collectionView!.numberOfItemsInSection(0)).map { (i) -> CroupierCollectionViewLayoutAttributes in let attributes = CroupierCollectionViewLayoutAttributes(forCellWithIndexPath: NSIndexPath(forItem: i, inSection: 0)) // set the layout values here ! return attributes } } subclassing UICollectionViewLayout
case .grid: return GridCollectionViewLayout() case .deck: return DeckCollectionViewLayout() case .fan: return CircularCollectionViewLayout() case .scatter: return ScatterCollectionViewLayout() case .spread: return SpreadCollectionViewLayout() } }
collectionView!.addGestureRecognizer(longPressRecogniser) func handleLongPress(recogniser: UILongPressGestureRecognizer){ let location = recogniser.locationInView(collectionView) let indexPath = indexPathForLocation(location) switch recogniser.state { case .Began: // track the indexPath // create snapshot of touch cell & add as subview of collection view, hide the original cell case .Changed: // if we're over a new indexPath switch it with the original in the dataSource // call moveItemAtIndexPath on the collection view ! case .Ended: // grab the cell with indexPath from .Began and set it to the new indexPath // hide the snapShot default: } ! }