设置文字段落属性

// 设置段落属性
    NSMutableAttributedString *text = [[NSMutableAttributedString alloc] initWithString:subTitleLabel.text];
    NSMutableParagraphStyle *style = [[NSMutableParagraphStyle alloc]init];
    style.firstLineHeadIndent = 20;
    style.tailIndent = -20;
    style.headIndent = 20;
    style.lineSpacing = 3;//行距
    style.alignment = NSTextAlignmentCenter;
    //需要设置的范围
    NSRange range = NSMakeRange(0, subTitleLabel.text.length);
    [text addAttribute:NSParagraphStyleAttributeName value:style range:range];
    subTitleLabel.attributedText = text;

你可能感兴趣的:(设置文字段落属性)