I'm building a mosaic view using UICollectionView
.
I have subclassed UICollectionViewFlowLayout
to layout a fixed grid that can be scrolled both horizontally and vertically. I have also attached a UIPinchGestureRecognizer
so the collection can scaled/zoomed.
Each cell in the collection contains a UIImage
with some transparency. I want to add a background image that will scroll and zoom with the cells.
I've attempted a number of different solutions.
- setting the background color of the
UICollectionView
usingcolorWithPatternImage
. (does not scroll/resize with content) - setting a background image view on each cell to the relevant cropped portion of the background image. (uses far too much memory)
I've been looking into Supplementary and Decoration Views but struggling to get my head around it. I think I need to use Supplementary views as the image used in the background will change depending on the datasource
.
What I don't understand is how I can register just one Supplementary View to span the width and height of the whole collectionview
. They seem to be tied to an indexPath
i.e each cell.