变更记录
方案名称
UIView \ UIButton - 独占响应事件
关键字
UIView \ UIButton \ 独占响应事件 \ 同时点击
需求场景
- 避免两个按钮(UIButton)很近的时候同时触发事件
- 避免同时点击多个按钮(UIButton)
参考链接
- IOS 开发两个按钮(button)很近的时候同时触发事件解决的方法(setExclusiveTouch)
- UIView独占响应事件
详细内容
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17
| _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;
|
效果图
(无)
备注