The purpose of prepareForReuse
is
to clean up, to prepare the view for use again. <...> to reset properties to their default values and generally make the view ready to use again.
Actually, layoutAttributesForItemAtIndexPath:
is the place where you need to set appropriate cell sizes.
Moreover, custom collection view layout should implement collectionViewContentSize
Subclasses must override this method and use it to return the width and height of the collection view’s content. These values represent the width and height of all the content, not just the content that is currently visible. The collection view uses this information to configure its own content size for scrolling purposes.
That means, collection view layout should be aware of available space and adjust content appropriately (if your goal is to fit content)