我有这个奇怪的问题,在 iOS 7 中我的应用程序 UIStatusBar
看起来像这样:
但在 iOS 6.1 中,UIStatusBar
看起来像这样:
所以,我知道问题出在哪里,这是因为我覆盖了 systemFontOfSize
和 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
如何在不影响 iOS6.1 中的 UIStatusBar
的情况下覆盖系统字体?
最佳答案
不不不!
不要使用这样的类别,它有意想不到的行为,您应该始终为您的类别方法命名空间。
例如
@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
然后您必须在您拥有的任何标签上明确设置字体。
myLabel.font = [UIFont oka_systemFontOfSize:17.f];
关于ios - iOS 6.1 状态栏字体变化,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/21219084/