How can I prevent a UITextView from drawing a long caret when I've specified a large paragraph spacing in iOS?

239 views Asked by At

I'm setting paragraph style like so:

NSTextStorage *textStorage = self.textView.textStorage;
NSMutableParagraphStyle *paragraphStyle = [[NSParagraphStyle defaultParagraphStyle] mutableCopy];
paragraphStyle.paragraphSpacing = FBTweakValue(@"Authoring View", @"Paragraph Style", @"Paragraph Spacing", 40.f);

[textStorage setAttributes:@{NSParagraphStyleAttributeName : paragraphStyle} range:[textStorage fullRange]];

screenie

EDIT: I found a partial answer below — it fixes the single line caret fine. However, when you drag out the selection range over a number of words, you get this:

enter image description here

Back to square one! How can you specify the height of the caret then?

NB: My question was posted once before on StackOverflow, but it was unceremoniously deleted. If you're going to do that, please at least give me a reason. Thanks SO.

1

There are 1 answers

0
fatuhoku On

Okay, I found an answer under slightly different wording — check out iOS - UITextView lineSpacing make cursor height not same

EDIT: I found that the possible duplicate question + solution is only a partial solution as it doesn't fix the caret if you select a range of characters.