赞
踩
.h文件内容
#import <UIKit/UIKit.h>
typedef void (^ButtonBlock)(UIButton *);
@interface BlockButton : UIButton
- (void)addTapBlock:(ButtonBlock)block;
@end
.m文件内容
#import “BlockButton.h”
@interface BlockButton() @property(nonatomic,copy) ButtonBlock block; @end @implementation BlockButton - (void)addTapBlock:(ButtonBlock)block { _block = block; [self addTarget:self action:@selector(buttonAction:) forControlEvents:UIControlEventTouchUpInside]; } - (void)buttonAction:(UIButton *)button { _block(button); } @end
Copyright © 2003-2013 www.wpsshop.cn 版权所有,并保留所有权利。