我已经搜索了一些页面。我发现了如下的答案代码...

NSMutableParagraphStyle *para = [[[NSParagraphStyle defaultParagraphStyle] mutableCopy] autorelease];

[para setLineSpacing:message.defaultParagraphStyle.lineSpacing + (float)2.5];

[message setDefaultParagraphStyle:(NSParagraphStyle*)para];


但是似乎没有用。有什么想法或任何错误的用法吗?

最佳答案

可以做到:

CGFloat spacing = 55.0f;
NSMutableParagraphStyle *para =[[[NSParagraphStyle defaultParagraphStyle] mutableCopy] autorelease];
[para setLineSpacing:spacing];
[para setMinimumLineHeight:spacing];
[para setMaximumLineHeight:spacing];
[yourTextView setDefaultParagraphStyle:para];

NSString *stringWithLineBreak = @"test \n test text \n more test text \n";
[yourTextView setString:stringWithLineBreak];

关于macos - 如何更改NSTextView的lineSpacing?,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/9294089/

10-09 16:04