美文网首页iOS开发
UILabel首行缩进

UILabel首行缩进

作者: Accepted_ | 来源:发表于2017-03-11 11:45 被阅读115次

使用NSMutableParagraphStyle和NSAttributeString类

NSMutableParagraphStyle*style = [[NSParagraphStyle defaultParagraphStyle] mutableCopy];

//对齐方式

style.alignment = NSTextAlignmentLeft;

//首行缩进

style.firstLineHeadIndent=40.0f;

NSAttributedString*attrText = [[NSAttributedString alloc] initWithString:@"shibushisssssss我们就是shibushisssssss我们就是11111111" attributes:@{NSParagraphStyleAttributeName: style}];

self.contentlabel.numberOfLines =0;

self.contentlabel.attributedText = attrText;

运行效果:

UILabel首行缩进

相关文章

网友评论

    本文标题:UILabel首行缩进

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