Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

comlog/FontChange

Open more actions menu

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

1 Commit
1 Commit
 
 
 
 
 
 

Repository files navigation

FontChange

iOS FontChange

iOS 利用runtime 实现全局字体的改变

创建UIFont的类别 UIFont+GHFont.h,UIFont+GHFont.m

  • (void)load{ static dispatch_once_t onceToken; dispatch_once(&onceToken, ^{ /利用runtime 实现当调用系统systemFontOfSize:获取字体的时候,调用指定的方法ghFontOfSize 从而重新设置字体/ kDefultFontName_GH = [UIFont systemFontOfSize:10].fontName; Class class = [self class]; Method originalMethod = class_getClassMethod(class, @selector(systemFontOfSize:)); Method swizzledMethod = class_getClassMethod(class, @selector(ghFontOfSize:)); method_exchangeImplementations(originalMethod, swizzledMethod);

    }); }

  • (UIFont *)ghFontOfSize:(CGFloat)fontSize {

    GHFontManager *manager = [GHFontManager sharedFontManager]; NSString *fontName = manager.fontName;
    if (fontName == nil) { fontName = kDefultFontName_GH; } return [UIFont fontWithName:fontName size:fontSize]; }

About

iOS FontChange

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published
Morty Proxy This is a proxified and sanitized view of the page, visit original site.