多行Lable 且首行有图标需要缩进

在多行Lable 且首行有图标需要缩进时使用如下处理方法可实现;

NSString *title = @"测试标题无可无不可测试标题无可无不可测试标题无可无不可无可无不可测试标题无可无不可";

    NSMutableParagraphStyle *paragraphStyle = [NSMutableParagraphStyle new];
    paragraphStyle.firstLineHeadIndent = 50;
    
    _titleLabel.attributedText = [[NSAttributedString alloc]
                                  initWithString:title
                                  attributes:@{NSParagraphStyleAttributeName: paragraphStyle}];

发表评论

您的电子邮箱地址不会被公开。