Joshua
Joshua

Reputation: 15510

Setting the Line Height/ Line Spacing in an NSTextView

How would I set the Line Height or Line Spacing in an NSTextView (i.e. how tall each line is, or how much space is between each line)?

Upvotes: 9

Views: 11023

Answers (2)

Michael
Michael

Reputation: 1485

Use the - (void)setDefaultParagraphStyle:(NSParagraphStyle *)paragraphStyle method in your NSTextView.

Documentation on NSParagraphStyle

Documentation on NSMutableParagraphStyle

There is a setLineSpacing: method in NSMutableParagraphStyle. There are also methods relating to line height, the methods under "Setting Other Style Information" in the NSMutableParagraphStyle documentation should prove useful.

I think that's what you're looking for.

Upvotes: 14

Jiulong Zhao
Jiulong Zhao

Reputation: 1363

leave the answer in case someone need:

NSMutableParagraphStyle * myStyle = [[NSMutableParagraphStyle alloc] init];
[myStyle setLineSpacing:10.0];
[myTextView setDefaultParagraphStyle:myStyle];

Upvotes: 21

Related Questions