Last active
August 29, 2015 14:24
-
-
Save maninp/514b695fd2a34015de43 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
- (CGRect)getMaxFrameForText:(UILabel *)label { | |
label.numberOfLines = 0; | |
label.lineBreakMode = NSLineBreakByWordWrapping; | |
CGRect currentFrame = label.frame; | |
CGSize max = CGSizeMake(label.frame.size.width, 250); | |
CGRect textRect = [label.text boundingRectWithSize:max options:NSStringDrawingUsesLineFragmentOrigin attributes:@{NSFontAttributeName:label.font} context:nil]; | |
currentFrame.size.height = ceilf(textRect.size.height); | |
return currentFrame; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment