在NSTextView设置行高/行距

问题描述 投票:6回答:2

我将如何设置在NSTextView行高或行距(即每行有多高,或有多少空间是每行之间)?

objective-c cocoa alignment nstextview
2个回答
13
投票

请使用您的NSTextView方法- (void)setDefaultParagraphStyle:(NSParagraphStyle *)paragraphStyle

NSParagraphStyle文档

NSMutableParagraphStyle文档

有一个在NSMutableParagraphStyle一个setLineSpacing:方法。也有与行高的方法,根据NSMutableParagraphStyle文档中的“设置其他样式信息”的方法应该是有用的。

我想这就是你要找的内容。


20
投票

离开万一有人需要的答案:

NSMutableParagraphStyle * myStyle = [[NSMutableParagraphStyle alloc] init];
[myStyle setLineSpacing:10.0];
[myTextView setDefaultParagraphStyle:myStyle];
© www.soinside.com 2019 - 2024. All rights reserved.