我有以下代码在 iOS 6 中完美运行,问题是它在 iOS 7 中没有任何效果。如何在 iOS 7 中应用字距和行距?
+ (NSAttributedString *)attributedText:(NSString *)text inFont:(UIFont *)font {
NSMutableAttributedString *attributedString = [[NSMutableAttributedString alloc] initWithString:text];
NSMutableParagraphStyle *style = [NSMutableParagraphStyle new];
style.lineSpacing = 5;
CGFloat kernSize = -0.6;
[attributedString addAttribute:NSParagraphStyleAttributeName value:style range:NSMakeRange(0, text.length)];
[attributedString addAttribute:NSKernAttributeName value:@(kernSize) range:NSMakeRange(0, text.length)];
return attributedString;
}