实现方法一:重写UIButton, 设置一个代理CustomButtonDelegate
@optional
-(void)buttonTouchedDown:(UIButton*)button;
-(void)buttonTouchedUpOutside:(UIButton*)button;
-(void)buttonTouhedCancelled:(UIButton*)button;
-(void)buttonTouchedLongTime:(UIButton*)button;
@end
-(id)init{
If(self = [super init]){
self.showsTouchWhenHighlighted = YES;
[self addTarget:self action:@selector(buttonTouchedDown:) forControlEvents:UIControlEventTouchDown];
[self addTarget:self action:@selector(buttonTouchedUpOutside:) forControlEvents: UIControlEventTouchUpOutside];
[self addTarget:self action:@selector(buttonTouhedCancelled:) forControlEvents:UIControlEventTouchCancell];
UILongPressGestureRecognizer *longPress = [[UILongPressGestureRecognizer alloc] initWithTarget:self action:@selector(buttonTouchedLongTime:)];
longPress.minimumPressDuration = 0.8; //定义按的时间
[self addGestureRecognizer:longPress];