-
-
Save onmyway133/8b4330ecba21de7aa9c2f257a0d51f5a to your computer and use it in GitHub Desktop.
This file contains 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
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