Reputation: 99
I am doing app related to custom alert. Written code for displaying alert view with transparent background when i click ok button on alert-view an alert disappears.
I need help for same thing happen while i touch the transparent view also my code is a below :
- (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];
}
Upvotes: 0
Views: 663
Reputation: 612
Create a custom transparent view then override this method
-(void)touchesEnded:(NSSet *)touches withEvent:(UIEvent *)event
Add your alert view into this view and use this view as full screen view.
You can use event
param to calculate to know user touch inside or outside of alertview.
Upvotes: 2