@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 点击区域屏蔽
最后编辑于 :
©著作权归作者所有,转载或内容合作请联系作者
- 文/潘晓璐 我一进店门,熙熙楼的掌柜王于贵愁眉苦脸地迎上来,“玉大人,你说我怎么就摊上这事。” “怎么了?”我有些...
- 文/花漫 我一把揭开白布。 她就那样静静地躺着,像睡着了一般。 火红的嫁衣衬着肌肤如雪。 梳的纹丝不乱的头发上,一...
- 文/苍兰香墨 我猛地睁开眼,长吁一口气:“原来是场噩梦啊……” “哼!你这毒妇竟也来了?” 一声冷哼从身侧响起,我...