2014-01-19 40 views
1

我有这个奇怪的问题,在iOS的7我的应用程序UIStatusBar看起来像这样:状态栏字体的变化6.1

ios7 status bar

但在iOS的6.1 UIStatusBar看起来像这样:

enter image description here

所以,我知道是什么问题,这是因为我重写了systemFontOfSizeboldSystemFontOfSize

#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 

如何覆盖系统字体而不影响iOS6.1中的UIStatusBar

回答

2

否否否!

不要使用这样的类别,它有意想不到的行为,你应该总是命名空间你的类别的方法。

例如

@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 

然后,您必须明确设置任何标签上的字体。类别和collisons

myLabel.font = [UIFont oka_systemFontOfSize:17.f]; 
+0

更多信息:http://cocoamanifest.net/articles/2011/06/clash-of-the-categories.html –

+0

是的,这可能就是我要做的事情。我想知道是否有办法解决这个问题,并保持这种状态。 –