我有一个子类化的UITableViewCell,其中包含一个UITextView。我已经在子类化的NSTextStorage中将NSParagraphStyle作为字符串属性添加了进去。在下面的代码中,我增加了UITextView中每一行之间的间距。
Swift
let paragraphStyle = NSMutableParagraphStyle()
paragraphStyle.lineSpacing = 11
myCustomTextStorage.appendAttributedString(NSAttributedString(string: someText, attributes: [NSParagraphStyleAttributeName: paragraphStyle]))
光标高度会延长到下一行的高度,如下图所示。这只会发生在最后一行之前的行。 我看了几篇关于此问题的stackoverflow帖子,包括这个帖子,然而,没有一个提出的解决方案对我起作用。
我已经阅读了TextKit文档,但没有找到此问题的解决方案。
是否有一种方法可以减小光标的高度?