行间距在NSMutableAttributedString中不起作用?

时间:2014-06-21 01:10:37

标签: ios iphone cocoa-touch nsattributedstring

我有一个自定义文本视图,我使用CoreText构建。我正在以下列方式设置文本的属性:

self.font = [UIFont fontWithName:self.fontName size:self.fontSize];

self.paragraphStyle = [[NSMutableParagraphStyle alloc] init];
self.paragraphStyle.alignment = alignment;
self.paragraphStyle.lineSpacing = lineSpacing;
self.paragraphStyle.firstLineHeadIndent = indent;
self.paragraphStyle.headIndent = indent;
self.paragraphStyle.tailIndent = -indent;

NSDictionary *attributes = [NSDictionary dictionaryWithObjectsAndKeys:
                                   self.paragraphStyle, NSParagraphStyleAttributeName,
                                    self.font, NSFontAttributeName,
                                    self.textColor, NSForegroundColorAttributeName,nil];
    [self.text insertAttributedString:[[NSAttributedString alloc] initWithString: text] atIndex:self.cursor.position];
[self.text addAttributes: attributes range:NSMakeRange(self.cursor.position, 1)];

我没注意到lineSpacing根本没有工作的最长时间!我已经读过其他问题,这是iOS6中的一个错误,但是在iOS7中我仍然遇到同样的问题。有些人说要弄乱minimumLineHeightmaximumLineHeight,但我只是得到了不可预知的结果。我无法更改NSFontAttribute(这是必需的,因此我可以使用CoreData保存属性)。

当我开始尝试将外国键盘调整到我的应用程序时,我偶然发现了这一点,我注意到中文,阿拉伯语,日语和俄语的字体在文本行之间都有很大的空白空间,我无法调节

有没有人知道这个问题的解决方案能以某种方式调整lineSpacing

0 个答案:

没有答案