Reputation: 13347
I have uilabel and this uilabel should grow in rows depending on the length of the text. Anyway I don't know how to do it. I already searched for different solution on the net but did not find anything that works as i want. currently I'm doing this here:
size_label = [[UILabel alloc] init];
size_label.frame = CGRectMake( 0, 0, 180, 10000);
size_label.font = [UIFont systemFontOfSize:15];
size_label.text = some_long_text;
size_label.numberOfLines = 10000;
[size_label sizeToFit];
NSLog(@"size_label.frame.size.height = %f", size_label.frame.size.height );
The result of NSLog is always 19. This is not what I want because the text would a least require like 150 pixels.
How do I get depending on:
the
such that everything is shown and the text just fits fine.
Upvotes: 0
Views: 233
Reputation: 1341
Foll code might help to autosize label
UILabel *size_label = [[UILabel alloc] initWithFrame:CGRectMake(0.0, 0.0, 180.0, 40.0);
size_label.font = [UIFont systemFontOfSize:15];
size_label.text = some_long_text;
size_label.numberOfLines = 0;
[size_label sizeToFit];
Upvotes: 1