美文网首页
iOS label行间距和缩进

iOS label行间距和缩进

作者: 夏天爱西瓜汁 | 来源:发表于2017-11-28 11:18 被阅读110次

2016.12.7

NSMutableParagraphStyle*paraStyle = [[NSMutableParagraphStylealloc]init];

paraStyle.lineBreakMode=NSLineBreakByCharWrapping;

paraStyle.alignment=NSTextAlignmentJustified;

paraStyle.lineSpacing=10;//设置行间距

paraStyle.firstLineHeadIndent=10.0;//首行缩进

paraStyle.paragraphSpacingBefore=5.0;//段首行空白空间

paraStyle.headIndent=10.0;//头部缩进,相当于左padding首行除外

paraStyle.tailIndent= -10.0;//相当于右padding

//设置字间距NSKernAttributeName:@1.5f

NSDictionary*dic =@{NSFontAttributeName:font,NSParagraphStyleAttributeName:paraStyle,NSKernAttributeName:@1.5f};

NSAttributedString*attributeStr = [[NSAttributedStringalloc]initWithString:strattributes:dic];

label.attributedText= attributeStr;

相关文章

网友评论

      本文标题:iOS label行间距和缩进

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