I'm using NSMutableParagraphStyle in my UITextview for adding linespace between each row text.
When I type something in textview, cursor height is normal. but when I move cursor position to text on the 2nd row (not the last row), cursor height is getting bigger.
What should I do to make cursor height normal in every row of the texts?
This is code I'm currently using:
NSMutableParagraphStyle *paragraphStyle = [[NSMutableParagraphStyle alloc] init];
paragraphStyle.lineSpacing = 30.;
textView.font = [UIFont fontWithName:@"Helvetica" size:16];
textView.attributedText = [[NSAttributedString alloc] initWithString:@"My Text" attributes:@{NSParagraphStyleAttributeName : paragraphStyle}];
解决方案
Finally I get solution that solves my problem.
Changing the cursor height is possible by subclassing the UITextView, then overriding the caretRectForPosition:position function. For Example:
- (CGRect)caretRectForPosition:(UITextPosition *)position {
CGRect originalRect = [super caretRectForPosition:position];
originalRect.size.height = 18.0;
return originalRect;
}