Last active
August 29, 2015 13:56
-
-
Save mamaz/9066782 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)getLabelSizeWordWrapWithString:(NSString*)string font:(UIFont*)font | |
constrainedToSize:(CGSize)constrainedSize | |
{ | |
if (IOS_VERSION_LESS_THAN_7) { | |
CGSize size = [string sizeWithFont:font | |
constrainedToSize:constrainedSize | |
lineBreakMode:NSLineBreakByWordWrapping]; | |
return size; | |
} else { | |
// for iOS7 | |
CGRect rect = [string boundingRectWithSize:constrainedSize | |
options:NSStringDrawingUsesLineFragmentOrigin|NSStringDrawingUsesFontLeading | |
attributes:@{NSFontAttributeName: font} | |
context:nil]; | |
return CGRectIntegral(rect).size; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment