A Tour of UICollectionView
Show Apple's description.
UICollectionView is a flexible, powerful tool to help you achieve great user experiences in your applications. Hear how you can leverage these rich APIs to rapidly move from initial design ideas to polished shipping applications. Topics range from getting started to advanced update animations and layouts.
prepare() method is called whenever the layout is invalidated, and in the case of
UICollectionFlowLayout, our layout is invalidated whenever the
UICollectionView's bounds of size changes.
For example when our app rotates on a phone or when our app is resized on an iPad. This is a great place to do any customization that takes the size of the
UICollectionView into account.