如果按照常规方法去写这个过程,代码如下:
@interface ViewController ()
@property (nonatomic, strong) UIButton * button;
@end
@implementation ViewController
- (void)viewDidLoad {
[super viewDidLoad];
self.button = [[UIButton alloc] initWithFrame:CGRectMake(0, 0, 100, 100)];
self.button.backgroundColor = [UIColor redColor];
[self.button addTarget:self action:@selector(btnClicked) forCo