第28月第5天 uibutton交換方法
阿新 • • 發佈:2019-01-05
1.
//交換系統的方法 1 @implementation UIControl (MYButton) 2 + (void)load 3 { 4 Method a = class_getInstanceMethod(self, @selector(sendAction:to:forEvent:)); 5 Method b = class_getInstanceMethod(self, @selector(__my_sendAction:to:forEvent:)); 6 method_exchangeImplementations(a, b);7 } 8 @end //定義自己的點選事件 1 - (void)__my_sendAction:(SEL)action to:(id)target forEvent:(UIEvent *)event 2 { 3 if (self.my_ignoreEvent) return; 4 if (self.my_acceptEventInterval > 0) 5 { 6 self.my_ignoreEvent = YES; 7 [self performSelector:@selector(setMy_ignoreEvent:) withObject:@(NO) afterDelay:self.my_acceptEventInterval];8 } 9 [self __my_sendAction:action to:target forEvent:event]; 10 }
https://www.cnblogs.com/ruihaha/p/5886304.html