美文网首页
NSParagraphStyle - 段落设置

NSParagraphStyle - 段落设置

作者: 杨继磊 | 来源:发表于2021-12-25 12:54 被阅读0次

    偶尔用到了一下,顺便做个笔记。

        NSMutableParagraphStyle *paragraphStyle = [NSMutableParagraphStyle new];
        
        paragraphStyle.lineSpacing = 20.;// 行间距
        paragraphStyle.lineHeightMultiple = 1.5;// 行高倍数(1.5倍行高)
        paragraphStyle.firstLineHeadIndent = 30.0f;//首行缩进
        paragraphStyle.minimumLineHeight = 10;//最低行高
        paragraphStyle.maximumLineHeight = 20;//最大行高(会影响字体)
        
        paragraphStyle.alignment = NSTextAlignmentLeft;// 对齐方式
        paragraphStyle.defaultTabInterval = 144;// 默认Tab 宽度
        paragraphStyle.headIndent = 20;// 起始 x位置
        paragraphStyle.tailIndent = 320;// 结束 x位置(不是右边间距,与inset 不一样)
        
        paragraphStyle.paragraphSpacing = 44.;// 段落间距
        paragraphStyle.paragraphSpacingBefore = 44.;// 段落头部空白(实测与上边的没差啊?)
        
    
        paragraphStyle.lineBreakMode = NSLineBreakByWordWrapping;// 分割模式
        /*
         NSLineBreakByWordWrapping = 0,      // Wrap at word boundaries, default
         NSLineBreakByCharWrapping,  // Wrap at character boundaries
         NSLineBreakByClipping,  // Simply clip
         NSLineBreakByTruncatingHead, // Truncate at head of line: "...wxyz"
         NSLineBreakByTruncatingTail, // Truncate at tail of line: "abcd..."
         NSLineBreakByTruncatingMiddle // Truncate middle of line:  "ab...yz"
         */
    
        
        paragraphStyle.baseWritingDirection = NSWritingDirectionRightToLeft;// 段落方向
        /*
         NSWritingDirectionNatural       = -1,    // Determines direction using the Unicode Bidi Algorithm rules P2 and P3
         NSWritingDirectionLeftToRight   =  0,    // Left to right writing direction
         NSWritingDirectionRightToLeft   =  1
         */
        
    
     
    

    相关文章

      网友评论

          本文标题:NSParagraphStyle - 段落设置

          本文链接:https://www.haomeiwen.com/subject/bdedqrtx.html