Skip to content

Instantly share code, notes, and snippets.

@onmyway133
Created October 22, 2016 10:44
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 onmyway133/8b4330ecba21de7aa9c2f257a0d51f5a to your computer and use it in GitHub Desktop.
Save onmyway133/8b4330ecba21de7aa9c2f257a0d51f5a to your computer and use it in GitHub Desktop.
static void swizzleInstanceMethod(Class class, SEL originalAction, SEL swizzledAction) {
method_exchangeImplementations(class_getInstanceMethod(class, originalAction),
class_getInstanceMethod(class, swizzledAction));
}
static void swizzle() {
swizzleInstanceMethod(UIView.class, @selector(didMoveToSuperview),
@selector(ftg_didMoveToSuperview));
}
__attribute__((constructor)) static void FTGBorderConstructor(void) {
@autoreleasepool {
swizzle();
}
}
#pragma mark - UIView
@interface UIView (FTGBorder)
@end
@implementation UIView (FTGBorder)
- (void)ftg_didMoveToSuperview {
self.layer.borderWidth = 1;
self.layer.borderColor = [UIColor brownColor].CGColor;
[self ftg_didMoveToSuperview];
}
@end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment