// 调整行间距
NSMutableAttributedString *attributedString = [[NSMutableAttributedString alloc] initWithString:str];
NSMutableParagraphStyle *paragraphStyle = [[NSMutableParagraphStyle alloc] init];
// 设置文字居中
paragraphStyle.alignment = NSTextAlignmentCenter;
[paragraphStyle setLineSpacing:12];
[attributedString addAttribute:NSParagraphStyleAttributeName value:paragraphStyle range:NSMakeRange(0, [str length])];
txt.attributedText = attributedString;
iOS - UILabel设置行间距及文字居中
最新推荐文章于 2021-07-15 00:43:46 发布