所以基本上我有一个带有自定义行间距的attributionString的标签。它可以在iOS6上运行,但不能在iOS7上工作,我的间距比默认值小一点,但是甚至不接近它应该的位置。这是我的代码:
NSDictionary *textAttributes1 = @{ NSForegroundColorAttributeName: MUSTARD_TEXT, NSFontAttributeName:[BEBAS_FONT_DEFAULT_TO_SIZE20]};
NSMutableString *aux;
if(text)
aux = [[NSMutableString alloc] initWithString:[text uppercaseString]];
else
aux = [[NSMutableString alloc] initWithString:@"YES"];
NSMutableAttributedString *str = [[NSMutableAttributedString alloc] initWithString:aux];
[str addAttributes:textAttributes1 range:NSMakeRange(0, [aux length])];
NSMutableParagraphStyle *paragrahStyle = [[NSMutableParagraphStyle alloc] init];
[paragrahStyle setLineSpacing:-7];
[paragrahStyle setMaximumLineHeight:26];
[str addAttribute:NSParagraphStyleAttributeName value:paragrahStyle range:NSMakeRange(0, [aux length])];
[_label setAttributedText:str];
标签看起来像这样:
_label = [[UILabel alloc] init];
_label.backgroundColor = [UIColor clearColor];
_label.numberOfLines = 0;
_label.lineBreakMode = NSLineBreakByWordWrapping;
_label.preferredMaxLayoutWidth = 226;
线条之间的空间应该像2 px,在iOS6上效果很好但在iOS7上空间很大。有什么想法吗?