/ Published in: Objective C

This code will resize a UILabel so that the label is as small as it can be in both width and height, based on the text in it and the font used.
Expand |
Embed | Plain Text
Copy this code and paste it in your HTML
frame = CGRectMake(160, labelTitle2.frame.origin.y + labelTitle2.frame.size.height + 136, 270, 25); UILabel *labelContent3 = [[UILabel alloc] initWithFrame: frame]; labelContent3.text = @"click here."; labelContent3.textColor = UIColorFromRGB(0x606060); labelContent3.font = [UIFont fontWithName:@"HelveticaNeue-Bold" size:13]; labelContent3.backgroundColor = [UIColor clearColor]; labelContent3.textAlignment = UITextAlignmentLeft; labelContent3.numberOfLines = 0; maximumLabelSize = CGSizeMake(270,9999); expectedLabelSize = [labelContent3.text sizeWithFont:labelContent3.font constrainedToSize:maximumLabelSize lineBreakMode:labelContent3.lineBreakMode]; newFrame = labelContent3.frame; newFrame.size.height = expectedLabelSize.height; labelContent3.frame = newFrame; [cell.contentView addSubview:labelContent3]; [labelContent3 release];
Comments
