Skip to content

Commit

Permalink
added block button
Browse files Browse the repository at this point in the history
David Scharf committed Oct 9, 2013
1 parent c42987b commit 1d02d71
Showing 2 changed files with 62 additions and 0 deletions.
17 changes: 17 additions & 0 deletions src/BOTBlockButton/BOTBlockButton.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
//
// BOTBlockButton.h
// cma
//
// Created by David Scharf on 10/9/13.
//
//

#import <UIKit/UIKit.h>

@interface BOTBlockButton : UIButton

@property (copy) void (^touchUpBlock) ();
@property (copy) void (^touchDownBlock) ();


@end
45 changes: 45 additions & 0 deletions src/BOTBlockButton/BOTBlockButton.m
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
//
// BOTBlockButton.m
// cma
//
// Created by David Scharf on 10/9/13.
//
//

#import "BOTBlockButton.h"

@implementation BOTBlockButton

- (id)init
{
self = [super init];
[self registerEvents];
return self;
}

- (void) registerEvents
{
[self addTarget:self
action:@selector(touchUpEvent)
forControlEvents:UIControlEventTouchUpInside];

[self addTarget:self
action:@selector(touchDownEvent)
forControlEvents:UIControlEventTouchUpInside];
}

- (void) touchUpEvent
{
if ( self.touchUpBlock ) {
self.touchUpBlock();
}
}

- (void) touchDownEvent
{
if ( self.touchDownBlock ) {
self.touchDownBlock();
}
}

@end

0 comments on commit 1d02d71

Please sign in to comment.