我正在做与自定义警报相关的应用程序。当我单击警报视图上的“确定”按钮时,显示具有透明背景的警报视图的书面代码将消失。
在触摸透明视图时,我需要帮助,同时我的代码如下所示:
- (void)didCustomPopUpAlertLoad:(UIView *)parentView andtitle:(NSString *)strTitle {
[self setRootView:parentView];
self.lblAlertMessage.text = strTitle;
//Add alertview into transparent view to hide parent view interaction
UIView *transparentView = [[UIView alloc] initWithFrame:parentView.bounds];
[transparentView setBackgroundColor:[UIColor clearColor]];
[transparentView addSubview:self];
float x = (int)(transparentView.bounds.size.width - self.bounds.size.width)>>1;
float y = (int)(transparentView.bounds.size.height - self.bounds.size.height)>>2;
[self setFrame:CGRectMake(x, y+62, self.bounds.size.width, self.bounds.size.height)];
// [self setFrame:CGRectMake(x+10, y+62, self.bounds.size.width, self.bounds.size.height)];
[self.window addSubview:transparentView];
[self.window makeKeyAndVisible];
[[transparentView subviews]
makeObjectsPerformSelector:@selector(setUserInteractionEnabled:)
withObject:[NSNumber numberWithBool:FALSE]];
}
-(void)didCustomPopUpUnload{
[self.superview removeFromSuperview];
// Set up the fade-in animation
self.window = nil;
}
-(IBAction)didActionOkAlertPopUp:(id)sender{
[self didCustomPopUpUnload];
}
发布于 2014-12-31 01:38:03
创建自定义透明视图,然后重写此方法。
-(void)touchesEnded:(NSSet *)touches withEvent:(UIEvent *)event
将警报视图添加到此视图中,并将此视图用作全屏视图。您可以使用event
参数来计算,以了解用户在警报视图内外的触觉。
https://stackoverflow.com/questions/27718004
复制相似问题