Reputation: 690
I know people have asked this question a bunch of times alrdy on Stack, but the usual answer of changing "Lines: 0" and selecting "Line Breaks: Word Wrap" just isn't fixing it for me.
I am using Xcode 4.2 with a Storyboard. I have placed a UILabel on a View Controller and resized it to cover most of the View. I have changed "Lines" value to 0 and "Line Breaks" value to Word Wrap.
I have tried \n
in my string: @"This is my label text \n that's supposed to wrap."
Any ideas??
EDIT: I wasn't declaring any of the label's properties in my implementation file, only on the storyboard, so I have tried the following... But with no luck ;\ (font name and size and alignment work, but number of lines and break mode seem to do nothing.)
lblText.numberOfLines = 0;
lblText.font = [UIFont fontWithName:@"Helvetica" size:(15.0)];
lblText.lineBreakMode = UILineBreakModeWordWrap;
lblText.textAlignment = UITextAlignmentLeft;
Upvotes: 5
Views: 12625
Reputation: 3416
Try this
[lblText setFrame:CGRectMake(10, 21, 100, 250)];
lblText.text =@"This is my label text \n that's supposed to wrap.";
lblText.numberOfLines = 3;
lblText.font = [UIFont fontWithName:@"Helvetica" size:(15.0)];
lblText.lineBreakMode = UILineBreakModeWordWrap;
lblText.textAlignment = UITextAlignmentLeft;
Upvotes: 10