When you apply a paragraph style with non-default spacing to a UITextView.attributedText, the caret size changes for the last line of each paragraph.
For instance, this code:
let paragraphStyle = NSMutableParagraphStyle()
paragraphStyle.paragraphSpacing = 40
paragraphStyle.paragraphSpacingBefore = 20
textView.attributedText = NSAttributedString(string: "Lorem ipsum dolor sit amet, consectetur adipiscing elit. Aenean id sodales turpis.\nPraesent cursus, turpis ac venenatis tincidunt, dui massa volutpat nunc, id maximus nisl diam nec est.\nDonec lorem eros, imperdiet faucibus nibh vel, imperdiet laoreet purus. Curabitur ut mollis tellus. Fusce eleifend est placerat, gravida nisi nec, blandit sem. Duis a convallis sapien, in tincidunt augue. Nullam tristique libero sed leo iaculis hendrerit. Vestibulum volutpat pharetra nisi, eu ullamcorper elit semper ac.", attributes: [NSParagraphStyleAttributeName: paragraphStyle])Gives you this caret (link):
That looks ridiculously big to me, but I'm not sure if this is a bug or how it's intended to be. I've been trying to adjust by overriding caretRectForPosition(:), but it looks like there's no way to get all the details right for the caret calculation without resorting to private APIs.
Has anyone dealt with this before?