Last active
June 27, 2016 09:08
-
-
Save ramakser/16a2580b16cc9ba07f44a64eebbb7e41 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
- (CGSize)collectionView:(UICollectionView *)collectionView layout:(UICollectionViewLayout*)collectionViewLayout sizeForItemAtIndexPath:(NSIndexPath *)indexPath | |
{ | |
UITabBarItem *item = self.items[indexPath.row]; | |
CGSize size = CGSizeMake(100, 30); | |
CGRect expectedLabelSize = [item.title boundingRectWithSize:size options:NSStringDrawingUsesLineFragmentOrigin attributes:@{ NSFontAttributeName:[UIFont VWTextOfficeRegularWithSize:12] } context:nil]; | |
CGFloat height = CGRectGetHeight(collectionView.frame); | |
CGFloat width = ceilf(expectedLabelSize.size.width) + 40; | |
return CGSizeMake(width, height); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment