Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

iOS 5/6 vs iOS 7 multiline label line spacing

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

like image 911
efpies Avatar asked Sep 23 '13 17:09

efpies


2 Answers

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 */
}
like image 134
Léo Natan Avatar answered Oct 19 '22 13:10

Léo Natan


I used MSLabel in iOS5/6. After iOS7 released, MSLabel is still working normally.

Nothing different in labels between iOS5/6 and iOS7. You can try MSLabel at https://github.com/LemonCake/MSLabel

like image 41
Tuyen Nguyen Avatar answered Oct 19 '22 14:10

Tuyen Nguyen