UIbutton UIvew 事件

h文件


#import <Foundation/Foundation.h>


@interface HFTouchButton : UIButton

{

}


@end



m 文件

#import "HFTouchButton.h"


@implementation HFTouchButton


bool touchMoved;

- (id)initWithFrame:(CGRect)frame

{

    self = [super initWithFrame:frame];

    if (self) {

        // Initialization code

    }

    return self;

}

- (void)touchesBegan:(NSSet *)touches withEvent:(UIEvent *)event

{

    touchMoved = NO;

    [[self superviewtouchesBegan:touches withEvent:event];

    [super touchesBegan:touches withEvent:event];

}


- (void)touchesMoved:(NSSet *)touches withEvent:(UIEvent *)event

{

    touchMoved = YES;

    [[self superviewtouchesMoved:touches withEvent:event];

    [super touchesMoved:touches withEvent:event];

}


- (void)touchesEnded:(NSSet *)touches withEvent:(UIEvent *)event

{

[[self superviewtouchesEnded:touches withEvent:event];

    if (!touchMoved

{

[super touchesEnded:touches withEvent:event];

}

}


@end

你可能感兴趣的:(initialization)