【发布时间】:2014-06-16 00:12:05
【问题描述】:
我想增加 UILabel 单词之间的空格。 从下面的代码中,我能够增加字符之间的空间,但我想为单词做这件事
NSMutableAttributedString* attrStr = [[NSMutableAttributedString alloc] initWithString:string];
[attrStr addAttribute:NSKernAttributeName value:@(4.0) range:NSMakeRange(0, attrStr.length)];
任何帮助或指针将不胜感激。
提前致谢
【问题讨论】:
-
不要认为这是可能的。但是您可以做的是在单词之间插入“小空格字符”,或者为空格设置更大的字体可能会更有趣。或者你可能只为空间添加这个 kern 属性
-
ok,如何设置空格的紧缩属性?
-
尝试使用 initialString = @"ABC DEF",设置 NSKernAttributeName 范围为 NSMakeRange(3,1)。有用吗?
标签: ios7 ios6 uilabel nsattributedstring