Setting the Line Height/ Line Spacing in an NSTextView

你说的曾经没有我的故事 提交于 2019-12-09 11:47:37

问题


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)?


回答1:


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.




回答2:


leave the answer in case someone need:

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


来源:https://stackoverflow.com/questions/1958176/setting-the-line-height-line-spacing-in-an-nstextview

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!