Skip to content

Instantly share code, notes, and snippets.

@objectiveSee
Created October 25, 2013 05:17
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save objectiveSee/7149720 to your computer and use it in GitHub Desktop.
Save objectiveSee/7149720 to your computer and use it in GitHub Desktop.
@implementation UIFont (CustomSystemFont)
// swizzle methods for system fonts so we can use
+ (void)load
{
Method orig = class_getClassMethod([UIFont class], @selector(systemFontOfSize:));
Method swiz = class_getClassMethod([UIFont class], @selector(_systemFontOfSize:));
method_exchangeImplementations(orig, swiz);
orig = class_getClassMethod([UIFont class], @selector(boldSystemFontOfSize:));
swiz = class_getClassMethod([UIFont class], @selector(_boldSystemFontOfSize:));
method_exchangeImplementations(orig, swiz);
orig = class_getClassMethod([UIFont class], @selector(italicSystemFontOfSize:));
swiz = class_getClassMethod([UIFont class], @selector(_italicSystemFontOfSize:));
method_exchangeImplementations(orig, swiz);
}
+ (UIFont *)_systemFontOfSize:(CGFloat)fontSize
{
return [UIFont fontWithName:@"Helvetica" size:fontSize];
}
+ (UIFont *)_boldSystemFontOfSize:(CGFloat)fontSize
{
return [UIFont fontWithName:@"Helvetica-Bold" size:fontSize];
}
+ (UIFont *)_italicSystemFontOfSize:(CGFloat)fontSize
{
return [UIFont fontWithName:@"Helvetica-Light" size:fontSize];
}
@end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment