简体   繁体   中英

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

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]];

筛选

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:

在此处输入图片说明

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.

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.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM