Created
March 30, 2014 11:06
-
-
Save jeffbailey/9871153 to your computer and use it in GitHub Desktop.
Find the height of a string to dynamically determine the height of a label. New in iOS 7.
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)labelSizeForString:(NSString *)string fontSize:(CGFloat)fontSize | |
{ | |
return [string boundingRectWithSize:CGSizeMake(DETAIL_TEXT_LABEL_WIDTH, 2000.0) options:NSStringDrawingUsesLineFragmentOrigin attributes:@{NSFontAttributeName : [UIFont systemFontOfSize:fontSize]} context:nil].size; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment