Custom Collection View Layouts - raywenderlich.com€¦ · Swift Generics, Closures, Enums, and...

9
Custom Collection View Layouts Introduction

Transcript of Custom Collection View Layouts - raywenderlich.com€¦ · Swift Generics, Closures, Enums, and...

Page 1: Custom Collection View Layouts - raywenderlich.com€¦ · Swift Generics, Closures, Enums, and Switch Feb 6, 11:30 The Grid Advanced Debugging Feb 6, 1 1 Metropolitan Center Auto

Custom Collection View Layouts

Introduction

Page 2: Custom Collection View Layouts - raywenderlich.com€¦ · Swift Generics, Closures, Enums, and Switch Feb 6, 11:30 The Grid Advanced Debugging Feb 6, 1 1 Metropolitan Center Auto

Architecture

UICollectionView

UICollectionViewLayout

UICollectionViewLayoutAttributesUICollectionViewLayoutAttributesUICollectionViewLayoutAttributesUICollectionViewLayoutAttributes

UICollectionViewFlowLayout

UICollectionViewCell

UICollectionReusableView

Page 3: Custom Collection View Layouts - raywenderlich.com€¦ · Swift Generics, Closures, Enums, and Switch Feb 6, 11:30 The Grid Advanced Debugging Feb 6, 1 1 Metropolitan Center Auto

Key Methods

override func collectionViewContentSize() -> CGSize

override func prepareLayout()

override func layoutAttributesForElementsInRect(rect: CGRect) -> [AnyObject]?

Page 4: Custom Collection View Layouts - raywenderlich.com€¦ · Swift Generics, Closures, Enums, and Switch Feb 6, 11:30 The Grid Advanced Debugging Feb 6, 1 1 Metropolitan Center Auto

Parts 1-3: Pinterest

Subclass UICollectionViewLayout Dynamically Sized Cells Cache Layout Attributes Custom Cell Padding & Insets Custom Layout Attributes

Page 5: Custom Collection View Layouts - raywenderlich.com€¦ · Swift Generics, Closures, Enums, and Switch Feb 6, 11:30 The Grid Advanced Debugging Feb 6, 1 1 Metropolitan Center Auto

Parts 4-6: DIY

Subclass UICollectionViewFlowLayout Manipulate Supplementary Views Custom Layout Attributes Auto Layout

Page 6: Custom Collection View Layouts - raywenderlich.com€¦ · Swift Generics, Closures, Enums, and Switch Feb 6, 11:30 The Grid Advanced Debugging Feb 6, 1 1 Metropolitan Center Auto

Part 7: Sticky Headers

Subclass UICollectionViewFlowLayout Familiar UITableView Behaviour Self-contained Layout Override Two Methods

Page 7: Custom Collection View Layouts - raywenderlich.com€¦ · Swift Generics, Closures, Enums, and Switch Feb 6, 11:30 The Grid Advanced Debugging Feb 6, 1 1 Metropolitan Center Auto

Parts 8-10: Ultravisual

Subclass UICollectionViewLayout Interactive Layout Manipulate Target Content Offset Update Interface Elements

Page 8: Custom Collection View Layouts - raywenderlich.com€¦ · Swift Generics, Closures, Enums, and Switch Feb 6, 11:30 The Grid Advanced Debugging Feb 6, 1 1 Metropolitan Center Auto

Parts 11-13: Timbre

Subclass UICollectionViewFlowLayout Manipulate Cell Transform Parallax Effect Auto Layout View Clipping

Page 9: Custom Collection View Layouts - raywenderlich.com€¦ · Swift Generics, Closures, Enums, and Switch Feb 6, 11:30 The Grid Advanced Debugging Feb 6, 1 1 Metropolitan Center Auto

Challenge Time!