label 内容首行缩进2022-11-10 本文已影响0人 见路_不走 NSMutableParagraphStyle *style = [[NSParagraphStyle defaultParagraphStyle] mutableCopy]; // 对齐方式 style.alignment = NSTextAlignmentJustified; // 首行缩进 style.firstLineHeadIndent = 12.0f; // 头部缩进 style.headIndent = 12.0f; // 尾部缩进 style.tailIndent = -12.0f; NSAttributedString *attrText = [[NSAttributedString alloc] initWithString:title attributes:@{ NSParagraphStyleAttributeName : style}]; UILabel *label = [[UILabel alloc] initWithFrame:someFrame]; label.numberOfLines = 0; label.attributedText = attrText;