In this example, We have shared multiple lines of text in UILabel. We have shredOne just has to add the following code:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 | // Swift textLabel.lineBreakMode = .ByWordWrapping // or NSLineBreakMode.ByWordWrapping textLabel.numberOfLines = 0 // For Swift >= 3 textLabel.lineBreakMode = .byWordWrapping // notice the 'b' instead of 'B' textLabel.numberOfLines = 0 // Objective-C textLabel.lineBreakMode = NSLineBreakByWordWrapping; textLabel.numberOfLines = 0; // C# (Xamarin.iOS) textLabel.LineBreakMode = UILineBreakMode.WordWrap; textLabel.Lines = 0; |
Restored old answer (for reference and devs willing to support iOS below 6.0):
1 2 | textLabel.lineBreakMode = UILineBreakModeWordWrap; textLabel.numberOfLines = 0; |
If you like this question & answer and want to contribute, then write your question & answer and email to freewebmentor[@]gmail.com. Your question and answer will appear on FreeWebMentor.com and help other developers.