因为类别无法给类添加属性,这里主要利用runtime给button添加属性的方法给button设置响应间隔时间
1.创建UIButton的类别
在.h文件中
#import <UIKit/UIKit.h>
#define defaultInterval .7// 默认间隔时间
@interface UIButton (touch)
/**
* 设置点击时间间隔
*/
@property (nonatomic, assign) NSTimeInterval timeInterVal;
@end
2.引入 objc/runtime.h
在.m文件中
#import "UIButton+touch.h"
#import <objc/runtime.h>
@interface UIButton ()
/**
* bool 设置是否执行触及事件方法
*/
@property (nonatomic, assign) BOOL