- (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;
}
网友评论