h文件
#import<Foundation/Foundation.h>
@interfaceHFTouchButton :UIButton
{
}
@end
m 文件
#import"HFTouchButton.h"
@implementationHFTouchButton
booltouchMoved;
- (id)initWithFrame:(CGRect)frame
{
self= [superinitWithFrame:frame];
if(self) {
// Initialization code
}
returnself;
}
- (void)touchesBegan:(NSSet*)touches withEvent:(UIEvent*)event
{
touchMoved=NO;
[[selfsuperview]touchesBegan:toucheswithEvent:event];
[supertouchesBegan:toucheswithEvent:event];
}
- (void)touchesMoved:(NSSet*)touches withEvent:(UIEvent*)event
{
touchMoved=YES;
[[selfsuperview]touchesMoved:toucheswithEvent:event];
[supertouchesMoved:toucheswithEvent:event];
}
- (void)touchesEnded:(NSSet*)touches withEvent:(UIEvent*)event
{
[[selfsuperview]touchesEnded:toucheswithEvent:event];
if(!touchMoved)
{
[supertouchesEnded:toucheswithEvent:event];
}
}
@end