Created
January 23, 2015 09:02
-
-
Save zakol/82798fc51a0277563eea to your computer and use it in GitHub Desktop.
Revisions
-
Dawid created this gist
Jan 23, 2015 .There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,34 @@ #import <UIKit/UIKit.h> #import <objc/runtime.h> @interface UIStatusBar : NSObject @end @implementation UIStatusBar (CustomColor) + (void)load { static dispatch_once_t onceToken; dispatch_once(&onceToken, ^{ Class class = [self class]; SEL originalSelector = @selector(foregroundColor); SEL swizzledSelector = @selector(s_foregroundColor); Method originalMethod = class_getInstanceMethod(class, originalSelector); Method swizzledMethod = class_getInstanceMethod(class, swizzledSelector); BOOL didAddMethod = class_addMethod(class, originalSelector, method_getImplementation(swizzledMethod), method_getTypeEncoding(swizzledMethod)); if (didAddMethod) class_replaceMethod(class, swizzledSelector, method_getImplementation(originalMethod), method_getTypeEncoding(originalMethod)); else method_exchangeImplementations(originalMethod, swizzledMethod); }); } - (UIColor*)s_foregroundColor { return [UIColor redColor]; } @end