0

I have a UITextView and I am inserting images into using NSTextAttachment. The problem is that when the user moves the cursor after the image and begins to type text, instead of using the font used everywhere else in the UITextView, it resets to a smaller font.

How can I make sure that the font that is typed after an image is the same font as the one typed elsewhere?

Community
  • 1
  • 1
Senseful
  • 73,679
  • 56
  • 267
  • 405

1 Answers1

0

I ended up reseting the typingAttributes after each time the cursor is changed. I have not found any cases where this doesn't work as expected.

extension ViewController: UITextViewDelegate {
    func textViewDidChangeSelection(textView: UITextView) {
        textView.typingAttributes = defaultAttributes
    }
}
Senseful
  • 73,679
  • 56
  • 267
  • 405