写一个YQSAlertController继承于UIAlertController
- (void)viewDidAppear:(BOOL)animated {
[superviewDidAppear:animated];
UIView*superView =self.view.superview;
UITapGestureRecognizer *tap = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(closeAlert:)];
if(![superView.gestureRecognizerscontainsObject:tap]) {
[superViewaddGestureRecognizer:tap];
superView.userInteractionEnabled = YES;
}
}
- (void)closeAlert:(UITapGestureRecognizer*) gesture{
[self dismissViewControllerAnimated:YES completion:nil];
}