【问题标题】:Multiple paragraphSpacing in NSMutableParagraphStyleNSMutableParagraphStyle 中的多个段落间距
【发布时间】:2014-01-24 07:43:36
【问题描述】:

NSMutableParagraphStyle 中,paragraphSpacing 工作得非常好。

但我也在使用要点

当用户按下 Return(Enter) 时,new Paragraph 就会出现。

所以当用户在 Uitextview 中输入 bullet points 时,在两个 Points 之间,paragaph spacing 应该是 small,其余的段落间距都很高。

我的代码是...

    NSMutableParagraphStyle *paragraphStyle = [[NSMutableParagraphStyle alloc] init];
    paragraphStyle.minimumLineHeight = 0.f;
    paragraphStyle.maximumLineHeight = 16.f;
    paragraphStyle.firstLineHeadIndent = 16.0;
    paragraphStyle.paragraphSpacing = 7.0;
    paragraphStyle.lineSpacing = 5.0;
    paragraphStyle.headIndent = 16.0;
    paragraphStyle.lineBreakMode=NSLineBreakByWordWrapping;
    paragraphStyle.tailIndent=305.0;
    mutattstr1 = [[NSMutableAttributedString alloc] initWithAttributedString:txtViewOfNotes.attributedText];
    [mutattstr1  addAttribute:NSParagraphStyleAttributeName value:paragraphStyle range:NSMakeRange(0, mutattstr1.length)];
    [txtViewOfNotes setAttributedText:mutattstr1]; 

就像在这个文本视图中一样,我需要在两个项目符号行之间留出小空间。

那么,如何在 app.js 中获得多个行间距或段落间距或与此相关的任何其他内容。

欢迎任何类型的链接、想法、代码、dock...

【问题讨论】:

    标签: ios iphone nsattributedstring spacing paragraph


    【解决方案1】:

    您可以使用范围属性在一个NSAttributedStrings 中包含多个NSMutableParagraphStyle - 就像您已经完成的那样。

    您只需要检测每个NSMutableParagraphStyle 的位置并使用各种NSRange 进行申请。这就是“有趣”的部分。

    【讨论】:

    • 是的,但是当用户键入一个段落时,如果新段落带有项目符号点(意味着左侧有更多空间),那么它会波动并在删除文本时,文字也会波动。如果你解决了这个问题,那么问题就消失了。
    猜你喜欢
    • 2017-05-06
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2011-03-08
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多