![]() ![]() in my viewController subclass which owns the UICollectionView: Here's what I have now: // in MyHeaderReusableView.m Unfortunately, I can't access my collection view or it's flow layout from my instance of UICollectionReusableView, so I had to create a delegate method to pass the correct height back. The only thing that would resize my headerView was setting my collection view's flow layout's headerReferenceSize. I feel like this could be accomplished with the standard CollectionView (and associated elements) API + hooking into standard layout/display invalidation, but I just couldn't get it working. I got something working, but I'll admit, it feels kludgy. I'm aware of UICollectionViewFlowLayout's headerReferenceSize and collectionView:layout:referenceSizeForHeaderInSection: but not quite sure how I'd use them in this situation. ![]() How can I dynamically change the height of my collectionView's supplementary view (preferably animated)? The only problem is that the entire headerView doesn't grow, and the cells don't get pushed down. After tapping the headerView, setting numberOfLines to 0, and forcing a layout pass, height then gets recorded as 163.5. = I log height at the end of layoutSubviews, its value is 149 while the label is truncated and numberOfLines is set to 3. (IBAction)onHeaderTap:(UITapGestureRecognizer *)sender Here's my code so far: // MyHeaderReusableView.m Here's what happens after you tap the header: When the user taps anywhere on the header (supplementary) view, I want to switch the UILabel to 0 lines so all text displays, and grow the collectionView's supplementary view's height accordingly (preferably animated). Inside a UICollectionView's supplementary view (header), I have a multiline label that I want to truncate to 3 lines.
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |