Pregunta

I have this weird issue, in iOS 7 my application UIStatusBar looks like that:

ios7 status bar

But in iOS 6.1 the UIStatusBar looks like that:

enter image description here

So, I know what is the problem, it's because I'm overriding systemFontOfSize and boldSystemFontOfSize:

#import "UIFont+SytemFontOverride.h"

@implementation UIFont (SystemFontOverride)

#pragma clang diagnostic push
#pragma clang diagnostic ignored "-Wobjc-protocol-method-implementation"

+ (UIFont *)boldSystemFontOfSize:(CGFloat)fontSize;
{
    return [UIFont fontWithName:@"ArialHebrew-Bold" size:fontSize];
}

+ (UIFont *)systemFontOfSize:(CGFloat)fontSize
{
    return [UIFont fontWithName:@"Arial" size:fontSize];
}

#pragma clang diagnostic pop

@end

How can I override the system font without effect the UIStatusBar in iOS6.1?

¿Fue útil?

Solución

No No No!

Don't use a category like that, it has unexpected behaviour, you should always namespace your category methods.

e.g.

@implementation UIFont (OKASystemFontOverride)

+ (UIFont *)oka_boldSystemFontOfSize:(CGFloat)fontSize;
{
    return [UIFont fontWithName:@"ArialHebrew-Bold" size:fontSize];
}

+ (UIFont *)oka_systemFontOfSize:(CGFloat)fontSize;
{
    return [UIFont fontWithName:@"Arial" size:fontSize];
}

@end

You must then explicitly set the font on any labels you have.

myLabel.font = [UIFont oka_systemFontOfSize:17.f];
Licenciado bajo: CC-BY-SA con atribución
No afiliado a StackOverflow
scroll top