Skip to content

Instantly share code, notes, and snippets.

@mrsidique
Created September 27, 2012 23:10
Show Gist options
  • Save mrsidique/3797007 to your computer and use it in GitHub Desktop.
Save mrsidique/3797007 to your computer and use it in GitHub Desktop.
NSString *text = @"What\nIs\nUp?";
CGSize constraint = CGSizeMake(CELL_CONTENT_WIDTH - (CELL_CONTENT_MARGIN * 2), 20000.0f);
CGSize size = [text sizeWithFont:[UIFont systemFontOfSize:FONT_SIZE] constrainedToSize:constraint lineBreakMode:UILineBreakModeWordWrap];
CGFloat height = MAX(size.height, 44.0f);
CGFloat labelHeight = height + (CELL_CONTENT_MARGIN * 2);
UILabel *textLabel = [[UILabel alloc]initWithFrame:CGRectMake(15, 5, 250, labelHeight)];
textLabel.font = [UIFont systemFontOfSize:15];
textLabel.text = text;
textLabel.numberOfLines = 0;
textLabel.lineBreakMode = UILineBreakModeWordWrap;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment