ios - iOS 6.1 状态栏字体变化

标签 ios iphone objective-c uifont uistatusbar

我有这个奇怪的问题,在 iOS 7 中我的应用程序 UIStatusBar 看起来像这样:

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 的情况下覆盖系统字体?

最佳答案

不不不!

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

例如

@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/

相关文章:

iphone - 如何查询实际的应用版本字符串?

iphone - UIActionSheet 困惑的优雅解决方案

objective-c - 使用 iOS 8 size class 为 iPad 纵向和横向模式设计不同的 UI

ios - AFNetworking 2.0 响应对象处理

objective-c - Mac 应用程序不使用视网膜@2x 图像文件

MKUserLocation 点的 iOS 10 标题箭头

iphone - 从 IOS 应用程序注销的完美方法是什么?

ios - UICollectionView 的每个部分独立滚动?

ios - 在 iOS 设备上销售数字内容?

iOS模拟器忽略了一半的屏幕?