Created
April 13, 2017 10:10
-
-
Save obyknovenius/a9ee3267d3dd923a4c32f129b023c5d9 to your computer and use it in GitHub Desktop.
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 characters
#import <objc/runtime.h> | |
#import <UIKit/UIKit.h> | |
#import "NSObject+Swizzling.h" | |
@implementation NSObject (Swizzling) | |
+ (void)load { | |
static dispatch_once_t onceToken; | |
dispatch_once(&onceToken, ^{ | |
Class class = objc_getClass("UITabBarButton"); | |
NSString *selectorString = @"initWithImage:selectedImage:label:withInsets:tabBar:"; | |
Method originalMethod = class_getInstanceMethod(class, NSSelectorFromString(selectorString)); | |
Method swizzledMethod = class_getInstanceMethod(class, NSSelectorFromString([@"swizzled_" stringByAppendingString:selectorString])); | |
method_exchangeImplementations(originalMethod, swizzledMethod); | |
}); | |
} | |
- (id)swizzled_initWithImage:(id)image selectedImage:(id)selectedImage label:(id)label withInsets:(UIEdgeInsets)insets tabBar:(id)tabBar { | |
return [self swizzled_initWithImage:image selectedImage:selectedImage label:label withInsets:insets tabBar:tabBar]; | |
} | |
@end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment