<table class="text">
<tr class="li1"><td class="ln"><pre class="de1">1
2
3
4
<span class="xtra li2"><span class="de2">56
7
8
9
<span class="xtra li2"><span class="de2">1011
12
13
14
<span class="xtra li2"><span class="de2">1516 文字不在居中了。 //设置行间距为10 NSMutableParagraphStyle *warnParagraph = [[NSMutableParagraphStyle alloc] init]; NSMutableAttributedString *warnAttr = [[NSMutableAttributedString alloc] initWithString:tipsLabel.text]; [warnAttr addAttribute:NSParagraphStyleAttributeName value:warnParagraph range:NSMakeRange(0,tipsLabel.text.length)]; tipsLabel.attributedText = warnAttr; 代码。后来在这段代码后面再次设置 tipsLabel.textAlignment = NSTextAlignmentCenter; 文字就居中了。