- (void)viewDidLoad {
[superviewDidLoad];
// Do any additional setup after loading the view, typically from a nib.
UILabel* contentLabel = [[UILabelalloc]initWithFrame:CGRectMake(20,100,200,500)];
contentLabel.backgroundColor= [UIColorredColor];
contentLabel.numberOfLines=0;
[self.viewaddSubview:contentLabel];
NSString*_test=@"首行縮進根據字體大小自動調整間隔可自定根據需求隨意改變。。。。。。。";
NSMutableParagraphStyle*paraStyle01 = [[NSMutableParagraphStylealloc]init];
paraStyle01.alignment=NSTextAlignmentLeft;//對齊
/*
這里這里
*/
paraStyle01.headIndent=30.0f;//行首縮進 (0.0f是首行縮進)
//參數:(字體大小17號字乘以2,34f即首行空出兩個字符)
CGFloatemptylen = contentLabel.font.pointSize*2;
paraStyle01.firstLineHeadIndent= emptylen;//首行縮進
paraStyle01.tailIndent=0.0f;//行尾縮進
paraStyle01.lineSpacing=2.0f;//行間距
NSAttributedString*attrText = [[NSAttributedStringalloc]initWithString:_testattributes:@{NSParagraphStyleAttributeName:paraStyle01}];
contentLabel.attributedText= attrText;
}