我想让按钮的两行文本非常靠近(小行距)。我有以下代码:
NSMutableAttributedString *string = [[NSMutableAttributedString alloc] initWithString:@"50 WPM"];
NSMutableParagraphStyle *paragrapStyle = [[NSMutableParagraphStyle alloc] init];
paragrapStyle.alignment = NSTextAlignmentCenter;
paragrapStyle.lineSpacing = -10;
[string addAttribute:NSParagraphStyleAttributeName value:paragrapStyle range:NSMakeRange(0, string.length)];
UIFont *font1 = [UIFont systemFontOfSize:22.0];
[string addAttribute:NSFontAttributeName value:font1 range:NSMakeRange(0, string.length - 4)];
UIFont *font = [UIFont systemFontOfSize:15.0];
[string addAttribute:NSFontAttributeName value:font range:NSMakeRange(string.length - 3, 3)];
[string addAttribute:NSForegroundColorAttributeName value:[UIColor greenColor] range:NSMakeRange(0, string.length)];
[self.button setAttributedTitle:string forState:UIControlStateNormal];
但由于行间距不能为负数,它并没有像我希望的那样接近。它看起来像这样:
有什么办法可以让他们更亲近吗?