I want to set a custom NSTextStorage to a UITextView object created from a storyboard. If it's really needed I can consider subclassing of UITextView.
(I know if I created a UITextView object from the code I would be able to use a init(frame: CGRect, textContainer: NSTextContainer?) constructor.)
Swift is preferable.
This works for me:
final class SendTextViewController: BaseViewController {
@IBOutlet private var textView: UITextView!
private var textStorage = MentionTextStorage()
override func viewDidLoad() {
super.viewDidLoad()
textView.textStorage.removeLayoutManager(textView.layoutManager)
textStorage.addLayoutManager(textView.layoutManager)
}
}
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