@interface HomeQueryView()<UIGestureRecognizerDelegate>{
UIView *_mainView;
float _mainWidth;
float _mainHeigth;
}
@end
@implementation HomeQueryView
- (instancetype)init{
self = [super init];
if (self) {
self.alpha = 0;
[self initView];
[UIView animateWithDuration:0.3 animations:^{
self.alpha = 1;
} completion:^(BOOL finished) {
if (finished) {
}
}];
}
return self;
}
- (void)initView {
self.frame = CGRectMake(0, 0, SCREEN_WIDTH, SCREEN_HEIGHT);
self.backgroundColor = [UIColor colorWithWhite:0 alpha:0.4];
UITapGestureRecognizer *hideTap = [[UITapGestureRecognizer alloc]initWithTarget:self action:@selector(hideView)];
hideTap.delegate = self;
[self addGestureRecognizer:hideTap];
_mainWidth =300;
_mainHeigth = 200;
_mainView = [[UIView alloc]initWithFrame:CGRectMake(SCREEN_3SPACE(15), (SCREEN_HEIGHT-_mainHeigth)/2, _mainWidth, _mainHeigth)];
_mainView.backgroundColor = [UIColor whiteColor];
_mainView.layer.cornerRadius = SCREEN_3SPACE(8);
_mainView.layer.masksToBounds = YES;
[self addSubview:_mainView];
}
-(BOOL)gestureRecognizer:(UIGestureRecognizer *)gestureRecognizer shouldReceiveTouch:(UITouch *)touch
{
CGPoint touchPoint = [touch locationInView:self];
if (CGRectContainsPoint(_mainView.frame, touchPoint)) {
return NO;
}
return YES;
}
@end
UIview 点击区域屏蔽
最后编辑于 :
©著作权归作者所有,转载或内容合作请联系作者
【社区内容提示】社区部分内容疑似由AI辅助生成,浏览时请结合常识与多方信息审慎甄别。
平台声明:文章内容(如有图片或视频亦包括在内)由作者上传并发布,文章内容仅代表作者本人观点,简书系信息发布平台,仅提供信息存储服务。
【社区内容提示】社区部分内容疑似由AI辅助生成,浏览时请结合常识与多方信息审慎甄别。
平台声明:文章内容(如有图片或视频亦包括在内)由作者上传并发布,文章内容仅代表作者本人观点,简书系信息发布平台,仅提供信息存储服务。