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?
UILineBreakMode
is deprecated but not NSLineBreakMode
.
You should use NSLineBreakByCharWrapping
meaning that the word'll be cut after a character.
textView.textContainer.lineBreakMode = .byCharWrapping
Here is how you can do it in Objective-C
textView.textContainer.lineBreakMode = NSLineBreakByCharWrapping;
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With