开发者

Custom font in iOS

Ok,

using a custom f开发者_运维百科ont since 3.2 is pretty straightforward:

Load the font in resources bundle, specify it's name in plist and there you go, you can use is in a text field with [textField setFont...].

The thing is, i want to replace the font in every part of my app, say the navigation bar so it gets complicated, because it seems i have to replace every component with a custom one in order to set the font.

Is there any way to let the bloody thing know that i want the default font replaced with a custom one, in one step? Not in every bar item, and so...

Thanks!


Maybe a category on UIFont which redefines

+ (UIFont *)systemFontOfSize:(CGFloat)size {
    return [self fontWithName:@"YourFontName" size:size];
}

+ (UIFont *)boldSystemFontOfSize:(CGFloat)size {
    return [self fontWithName:@"YourBoldFontName" size:size];
}

to return your custom font.

As pointed by Jonathan in the comments, it may also change the status bar font (I can't verify at the moment). I don't know if Apple would accept this behavior (redefining methods is OK but modifying the default UI isn't IMHO).

Subclassing UIFont wouldn't be sufficient because labels and others would still use the UIFont class by default.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜