Re: Setting the Line Height/ Line Spacing in an NSTextView.

Christiaan Hofman <[email protected]>
Newsgroups gmane.comp.macosx.devel
Message-ID <[email protected]>
On Dec 31, 2009, at 17:04, Joshua Garnham wrote:

> How would I set the Line Height/ Line Spacing in an NSTextView? e.g How
> tall each line is or how much space is between each line.
> 
> 
> Here's what I've tried (but doesn't work), it is in a NSTextView subclass … 
> - (void)setDefaultParagraphStyle:(NSMutableParagraphStyle *)paragraphStyle {
>    CGFloat spacing = 5.0f;
>    [paragraphStyle setLineSpacing:spacing];
>    [paragraphStyle setMinimumLineHeight:spacing];
>    [paragraphStyle setMaximumLineHeight:spacing];
> }
> 
> What's gone wrong?

Uhm, why would you even think this to work? This method does nothing, except perhaps raise an exception (because the parameter is an NSParagraphStyle, not an NSMutableParagraphStyle). Moreover, it should be obvious (if you know anything about OOP programming) that to change the paragraph style you USE this method, not OVERRIDE it. Apart from that (and beside the point), any implementation of this method should at least do what it is supposed to do, which is SET the paragraph style, which your implementation most definitely does not.

Christiaan
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.