10

I ran my app under iOS 7 and discovered that multiline labels (non-attributed, plain text) render with a small line spacing. Anyone knows what to do it with iOS 5 compatibility?

iOS 5/6

iOS 5/6

iOS 7

iOS 7

4

2 回答 2

18
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 */
}
于 2013-09-23T21:37:00.023 回答
1

我在 iOS5/6 中使用了 MSLabel。iOS7 发布后,MSLabel 仍然正常工作。

iOS5/6 和 iOS7 之间的标签没有什么不同。您可以在https://github.com/LemonCake/MSLabel尝试 MSLabel

于 2013-10-07T08:18:49.610 回答