Skip to content

Instantly share code, notes, and snippets.

@romyilano
Created March 20, 2013 20:16
Show Gist options
  • Select an option

  • Save romyilano/5208055 to your computer and use it in GitHub Desktop.

Select an option

Save romyilano/5208055 to your computer and use it in GitHub Desktop.
Matt Neuberg - how to make text adjust in a UILabel - Programming iOS 5
// thank you matt neuberg!!!
-(CGRect)textRectForBounds:(CGRect)bounds
limitedToNumberOfLines:(NSInteger)numberOfLines {
CGSize sz = [self.text sizeWithFont:self.font
constrainedToSize:CGSizeMake(self.bounds.size.width, 10000)
lineBreakMode:self.lineBreakMode];
return (CGRect) {bounds.origin, CGSizeMake(self.bounds.size.width, sz.height)];
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment