iOS 一些不常用方法
2018-01-31 本文已影响0人
不懂代码的iOS
1.- (BOOL)isDescendantOfView:(UIView *)view; // returns YES for self.
使用isDescendantOfView方法来验证,是不是子类关系,不一定是直接子类。
// 弹框bgView
[self.view addSubview:self.showView];
// 创建一个轻拍手势 同时绑定了一个事件
UITapGestureRecognizer *aTapGR = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(tapGRAction:)];
aTapGR.delegate = self;
[self.view addGestureRecognizer:aTapGR];
代理方法,只是阴影背景响应这个手势,中间视图不响应
- (BOOL)gestureRecognizer:(UIGestureRecognizer *)gestureRecognizer shouldReceiveTouch:(UITouch *)touch{
if ([touch.view isDescendantOfView:self.showView]) {
return NO;
}
return YES;
}