Any way to have multiple lines of text in UILabel
like in the UITextView
?
I dont wish to use more than 1 label in the view.
Any way to have multiple lines of text in UILabel
like in the UITextView
?
I dont wish to use more than 1 label in the view.
Just use this code in your Program
textLabel.lineBreakMode = UILineBreakModeWordWrap;
textLabel.numberOfLines = 0;
Yes this can be done by setting the numerOfLines
property to the number of lines you want to display. Or set it to 0
if you just want to be able to add as many lines as you want.
You can check out this answer which has everything you want
You can also set Properties like numberoflines
and linebreakMode
have look to documentation as well
textLabel.lineBreakMode = UILineBreakModeWordWrap;
textLabel.numberOfLines = 0;
set the lineBreakMode
and numberOfLines
property of UILabel and set the frame as see the multiple lines.
yourLabel.lineBreakMode = UILineBreakModeWordWrap;
yourLabel.numberOfLines = 0;
yourLabel.frame = CGRectMake(0,0,320,150);
yes,this is possible in .xib file select your label you found Lines option set value that you want to i.e. line 3
if you creating label programmatic than
lbl.numberOfLines = 0;
CGRect currentFrame = myLabel.frame;
CGSize max = CGSizeMake(lbl.frame.size.width, 500);
CGSize expected = [myString sizeWithFont:lbl.font constrainedToSize:max lineBreakMode:lbl.lineBreakMode];
currentFrame.size.height = expected.height;
lbl.frame = currentFrame;