I want to be able to set the minimum height of the content size within a UICollectionView, so I can hide/show a UISearchbar, similar to the way it's done on iBooks.
However, I don't want to subclass the layout as I want to keep the standard vertical layout for a UICollectionView.
any ideas?
You can do this by subclassing UICollectionViewFlowLayout and overriding the method
-(CGSize)collectionViewContentSize
{ //Get the collectionViewContentSize
CGSize size = [super collectionViewContentSize];
if (size < minimumSize) return minimumSize;
else return size;
}
Edit: I just realized you said you didn't want to subclass the layout. Anyway, I subclassed UICollectionViewFlowLayout and only modified the collectionViewContentSize method. It kept the standard vertical layout for me.
Edit: https://stackoverflow.com/a/14465485/2017159. Here it says UICollectionViewFlowLayout only supports one direction (vertical or horizontal), so it should be fine?
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With