变更记录
序号 | 录入时间 | 录入人 | 备注 |
---|---|---|---|
1 | 2015-10-26 | Alfred Jiang | - |
2 | 2015-12-18 | Alfred Jiang | - |
方案名称
UIView \ UIButton - 独占响应事件
关键字
UIView \ UIButton \ 独占响应事件 \ 同时点击
需求场景
- 避免两个按钮(UIButton)很近的时候同时触发事件
- 避免同时点击多个按钮(UIButton)
参考链接
详细内容
_button1 = [[UIButton alloc] initWithFrame:CGRectMake(0, 0, 100, 100)];
[self.view addSubview:_button1];
_button1.backgroundColor = [UIColor redColor];
[_button1 addTarget:self
action:@selector(buttonsEvent:)
forControlEvents:UIControlEventTouchUpInside];
_button1.exclusiveTouch = YES;
_button2 = [[UIButton alloc] initWithFrame:CGRectMake(0, 100, 100, 100)];
[self.view addSubview:_button2];
_button2.backgroundColor = [UIColor greenColor];
[_button2 addTarget:self
action:@selector(buttonsEvent:)
forControlEvents:UIControlEventTouchUpInside];
_button2.exclusiveTouch = YES;
效果图
(无)