簡體   English   中英

iOS 6.1中的狀態欄字體更改

[英]Status bar font changes in iOS 6.1

我有這個奇怪的問題,在iOS 7中,我的應用程序UIStatusBar看起來像這樣:

ios7狀態欄

但是在iOS 6.1中, UIStatusBar看起來像這樣:

在此處輸入圖片說明

所以,我知道是什么問題,那是因為我重寫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];

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM