我在iOS 7上运行我的应用程序时发现多行标签(非属性化纯文本)呈现出小的行间距。有人知道如何处理iOS 5兼容性吗?
iOS 5/6
iOS 7
if(NSFoundationVersionNumber > NSFoundationVersionNumber_iOS_6_1)
{
NSFont *font = /* set font */;
NSMutableParagraphStyle *paragraphStyle = [[NSParagraphStyle defaultParagraphStyle] mutableCopy];
[paragraphStyle setLineSpacing: /* required line spacing */];
NSDictionary *attributes = @{ NSFontAttributeName: font, NSParagraphStyleAttributeName: paragraphStyle };
NSAttributedString *attributedString = [[NSAttributedString alloc] initWithString:@"strigil" attributes:attributes];
[label setAttributedText: attributedString];
}
else
{
/* old method */
}
alloc] init]
不会返回默认段落样式。 - Léo Natan我在iOS5/6中使用了MSLabel。 在iOS7发布后,MSLabel仍然正常工作。
iOS5/6和iOS7之间的标签没有任何区别。 你可以在https://github.com/LemonCake/MSLabel尝试使用MSLabel。