Advertisement
Guest User

Untitled

a guest
Oct 23rd, 2016
60
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.78 KB | None | 0 0
  1. static void swizzleInstanceMethod(Class class, SEL originalAction, SEL swizzledAction) {
  2. method_exchangeImplementations(class_getInstanceMethod(class, originalAction),
  3. class_getInstanceMethod(class, swizzledAction));
  4. }
  5.  
  6. static void swizzle() {
  7. swizzleInstanceMethod(UIView.class, @selector(didMoveToSuperview),
  8. @selector(ftg_didMoveToSuperview));
  9. }
  10.  
  11. __attribute__((constructor)) static void FTGBorderConstructor(void) {
  12. @autoreleasepool {
  13. swizzle();
  14. }
  15. }
  16.  
  17. #pragma mark - UIView
  18. @interface UIView (FTGBorder)
  19. @end
  20.  
  21. @implementation UIView (FTGBorder)
  22.  
  23. - (void)ftg_didMoveToSuperview {
  24. self.layer.borderWidth = 1;
  25. self.layer.borderColor = [UIColor brownColor].CGColor;
  26.  
  27. [self ftg_didMoveToSuperview];
  28. }
  29.  
  30. @end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement