NSParagraphStyle行间距
和富文本组合使用
NSMutableParagraphStyle*paragraphStyle = [NSMutableParagraphStylenew]; 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
*/
paragraphStyle.lineSpacing = 10;// 字体的行间距
paragraphStyle.firstLineHeadIndent = 20.0f;//首行缩进
paragraphStyle.alignment = NSTextAlignmentJustified;//(两端对齐的)文本对齐方式:(左,中,右,两端对齐,自然)
paragraphStyle.lineBreakMode = NSLineBreakByTruncatingTail;//结尾部分的内容以……方式省略 ( "...wxyz" ,"abcd..." ,"ab...yz")
paragraphStyle.headIndent = 20;//整体缩进(首行除外)
paragraphStyle.tailIndent = 20;//
paragraphStyle.minimumLineHeight = 10;//最低行高
paragraphStyle.maximumLineHeight = 20;//最大行高
paragraphStyle.paragraphSpacing = 15;//段与段之间的间距
paragraphStyle.paragraphSpacingBefore = 22.0f;//段首行空白空间/* Distance between the bottom of the previous paragraph (or the end of its paragraphSpacing, if any)
and the top of this paragraph. */
paragraphStyle.baseWritingDirection = NSWritingDirectionLeftToRight;//从左到右的书写方向(一共三种)
paragraphStyle.lineHeightMultiple = 15;/* Natural line height is multiplied by this factor (if positive)
before being constrained by minimum and maximum line height. */
paragraphStyle.hyphenationFactor = 1;//连字属性 在iOS,唯一支持的值分别为0和1