Reputation: 25701
I have a UITextView with the following text:
textView.text = @"aaa a a a a a a zzzzzzzzzzzzzzzzzzzzzzzzzzzzzz";
When I run it in the CGRect that I provided it goes like this:
aaa a a a a a a
zzzzzzzzzzzzzzzzzzzzzzz <-text view width ends here
zzzzzzz
But I want it to work like a UILabel with numberOfLines = 0, which gives me this:
aaa a a a a a a zzzzzz <-text view width ends here
zzzzzzzzzzzzzzzzzzzzzzz <-text view width ends here
z
With iOS 6, UILineBreakMode was deprecated. How do I achieve this now?
Upvotes: 9
Views: 17883
Reputation: 2483
Here is how you can do it in Objective-C
textView.textContainer.lineBreakMode = NSLineBreakByCharWrapping;
Upvotes: 1
Reputation: 2722
UILineBreakMode
is deprecated but not NSLineBreakMode
.
You should use NSLineBreakByCharWrapping
meaning that the word'll be cut after a character.
textView.textContainer.lineBreakMode = .byCharWrapping
Upvotes: 17