Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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?

like image 556
Abdullah Umer Avatar asked Jun 03 '14 12:06

Abdullah Umer


People also ask

How to have specific line spacing for attributed text in UITextView?

lineSpacinghas the following declaration: The distance in points between the bottom of one line fragment and the top of the next. var lineSpacing: CGFloat { get set } The following code shows how to implement lineSpacingin order to have a specific line spacing for some attributed text in your UItextView.

How important is line spacing for UX design?

The importance of line spacing for UX design comes from the power it has to render a block of text more or less readable. Line spacing is commonly measured as a percentage of font size. Conventional wisdom is that line spacing of 130%-150% is ideal for readability.

What is the default spacing in Microsoft Word?

Word's default spacing is 1.08 lines, which is somewhat more than single-spaced. You can change this by using the Format menu and selecting Line Spacing. What is the spacing in Microsoft Word? You may change the line spacing in Microsoft Word to be single spaced (one line high), double spaced (two lines high), or any other quantity you wish.

What is the best line spacing for text?

Line spacing is commonly measured as a percentage of font size. Conventional wisdom is that line spacing of 130%-150% is ideal for readability. In fact, anything from about 120% up to 200% is acceptable, but 140% tends to be the most quoted sweet spot.


1 Answers

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)

like image 81
Stonz2 Avatar answered Oct 05 '22 02:10

Stonz2