Nikunj Jadav Nikunj Jadav - 2 months ago 8
Objective-C Question

iOS : How can I set frame of UILabel according to its text?

I want to develop a functionality that to set frame of

according to its text means when text is change its frame is change? If yes, then please share any link or any idea to develop this.

Thanks in advance.


If you want to know needful height for some width you can use the code below:

NSString *yourString = @"My great text o0";
CGSize s = [yourString sizeWithFont:[UIFont systemFontOfSize:12] constrainedToSize:CGSizeMake(width, MAXFLOAT) lineBreakMode:UILineBreakModeWordWrap];
// s.height is your your height

For more information read here