
我该怎么做才能减少行高或行间距?缩小字体大小不是一种选择.
任何帮助将非常感激!
周末愉快,
!)
解决方法 作为参考,您想要阅读段落样式的这种描述: Cocoa Paragraph Styles并注意其中的所有内容都在行之间,段落之间,段落之间添加了额外的空间.您可以将NSMutableParagraphStyle中的值设置为零但不低.要进一步缩小行之间的间距,请使用setMaximumlineHeight,这要归功于代码的“6 1”(我添加了setMaximumlineHeight):
Nsstring *Title = @"Title here";NSFont *bold14 = [NSFont boldSystemFontOfSize:14.0];NScolor *textcolor = [NScolor redcolor];NSMutableParagraphStyle *textParagraph = [[NSMutableParagraphStyle alloc] init];[textParagraph setlinespacing:10.0]; // this sets the space BETWEEN lines to 10points[textParagraph setMaximumlineHeight:12.0]; this sets the MAXIMUM height of the lines to 12pointsNSDictionary *attrDic = [NSDictionary dictionaryWithObjectsAndKeys:bold14,NSFontAttributename,textcolor,NSForegroundcolorAttributename,textParagraph,NSParagraphStyleAttributename,nil];NSAttributedString *attrString = [[NSAttributedString alloc] initWithString:Title attributes:attrDic]; [self.TitleFIEld setAllowsEditingTextAttributes:YES];[self.TitleFIEld setAttributedStringValue:attrString];总结
以上是内存溢出为你收集整理的objective-c – Cocoa NSTextField行间距全部内容,希望文章能够帮你解决objective-c – Cocoa NSTextField行间距所遇到的程序开发问题。
如果觉得内存溢出网站内容还不错,欢迎将内存溢出网站推荐给程序员好友。
欢迎分享,转载请注明来源:内存溢出
微信扫一扫
支付宝扫一扫
评论列表(0条)