- Call sizeWithFont of the text.
- Get back a CGSize struct and you can now init your UILabel with the struct.
CGSize textSize = [ myText sizeWithFont: font constrainedToSize: CGSizeMake(lineWidth, lineHeight*1000.0f) lineBreakMode: UILineBreakModeTailTruncation ];
UILabel *l = [[UILabel alloc] initWithFrame:CGRectMake(10,10,textSize.width,textSize.height)];
This took me awhile to find out..hope it helps you. Happy coding.
No comments:
Post a Comment