http://www.cocoachina.com/bbs/read.php?tid=98584
下面是实现的核心逻辑,具体例子详见附件
self.button=[UIButton buttonWithType:UIButtonTypeCustom];
[self.button addTarget:self action:@selector(buttonTouchUpInside) forControlEvents:UIControlEventTouchUpInside];
[self.button addTarget:self action:@selector(buttonTouchUpOutside) forControlEvents:UIControlEventTouchUpOutside];
[self.button addTarget:self action:@selector(buttonTouchDown) forControlEvents:UIControlEventTouchDown];
//当按下按钮以后调用该方法,增加一个延迟。
- (void)buttonTouchDown
{
[self performSelector:@selector(lazyButtontouchDown) withObject:nil afterDelay:self.minimumPressDuration];
}
-(void)lazyButtontouchDown
{
}
//当离开按钮的时候取消所调用的方法
- (void)buttonTouchUpInside
{
[NSObject cancelPreviousPerformRequestsWithTarget:self
selector:@selector(lazyButtontouchDown)
object:nil];
}
- (void)buttonTouchUpOutside
{
[NSObject cancelPreviousPerformRequestsWithTarget:self
selector:@selector(lazyButtontouchDown)
object:nil];
}