關(guān)于首行縮進(jìn),iOS中時(shí)這樣處理的:
NSString *contentString; //需要首行縮進(jìn)的文字
UILabel *label = [[UILabel alloc] init];
NSMutableAttributedString *attributedString = [[NSMutableAttributedString alloc] initWithString:contentString];
NSMutableParagraphStyle *paragraphStyle = [[NSMutableParagraphStyle alloc] init];
paragraphStyle.firstLineHeadIndent = kPercenX_scale(32); //首行縮進(jìn)的距離
[attributedString addAttribute:NSParagraphStyleAttributeName value:paragraphStyle range:NSMakeRange(0, [contentString length])];
label.attributedText = attributedString;
[label sizeToFit];
效果圖如下:
首行未縮進(jìn).jpeg
處理后的效果.jpeg