2014-01-19 49 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

是的,這可能就是我要做的事情。我想知道是否有辦法解決這個問題,並保持這種狀態。 –