07
- (void)viewDidLoad {
[super viewDidLoad];
// Do any additional setup after loading the view.
UIImageView *imageView = [[UIImageView alloc] initWithFrame:CGRectMake(50, 50, 250, 250)];
//打开交互
imageView.userInteractionEnabled = YES;
imageView.backgroundColor = [UIColor greenColor];
[self.view addSubview:imageView];
UIButton *button = [UIButton buttonWithType:UIButtonTypeCustom];
button.frame = CGRectMake(50, 50, 150, 80);
[button setTitle:@"响应者链" forState:UIControlStateNormal];
[button setTitleColor:[UIColor blackColor] forState:UIControlStateNormal];
button.titleLabel.font = [UIFont boldSystemFontOfSize:19];//按钮是个组合控件
[button addTarget:self action:@selector(click) forControlEvents:UIControlEventTouchUpInside];
[imageView addSubview:button];
}
- (void)click {
NSLog(@"别摸我");
}