第28月第5天 uibutton交换方法

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

猜你喜欢

转载自www.cnblogs.com/javastart/p/10224611.html
今日推荐