Revision: 38932
Initial Code
Initial URL
Initial Description
Initial Title
Initial Tags
Initial Language
at January 10, 2011 20:10 by suibhne
Initial Code
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];
Initial URL
Initial Description
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.
Initial Title
Resize UILabel to Fit Font Size and Text
Initial Tags
iphone
Initial Language
Objective C