Abdullah Umer
Abdullah Umer

Reputation: 4624

What is the default line spacing in UITextView

I want to increase the default line spacing in UITextView by 10 units.

Here's how I am doing:

NSDictionary *attributesDictionary;
NSMutableParagraphStyle *paragraphStyle = [[NSMutableParagraphStyle alloc] init];
paragraphStyle.lineSpacing = 30;

attributesDictionary = @{NSParagraphStyleAttributeName : paragraphStyle , NSFontAttributeName: cellFont};

[str addAttributes:attributesDictionary range:NSMakeRange(0, str.length)];
bodyTextView.attributedText = str;

So what is the default value that I should add 10 with and set it the linespacing?

Upvotes: 6

Views: 4822

Answers (1)

Stonz2
Stonz2

Reputation: 6396

The default value is 0.

This can be shown by creating a UITextView with some text and set its font to Helvetica size 12 (which is the default of an NSAttributedString). If you then use your code above but set paragraphStyle.lineSpacing = 0 and remove whatever font you're setting in your attributesDictionary you can see that the spacing in your bodyTextView will be identical to the spacing in the non-attributed version. I am assuming that this holds true with other fonts (such as whatever you're using in cellFont)

Upvotes: 9

Related Questions