File tree Expand file tree Collapse file tree 2 files changed +14
-0
lines changed
CustomIOSAlertView/CustomIOSAlertView/View Expand file tree Collapse file tree 2 files changed +14
-0
lines changed Original file line number Diff line number Diff line change 2626@property (nonatomic , assign ) id <CustomIOSAlertViewDelegate> delegate;
2727@property (nonatomic , retain ) NSArray *buttonTitles;
2828@property (nonatomic , assign ) BOOL useMotionEffects;
29+ @property (nonatomic , assign ) BOOL closeOnTouchUpOutside; // Closes the AlertView when finger is lifted outside the bounds.
2930
3031@property (copy ) void (^onButtonTouchUpInside)(CustomIOSAlertView *alertView, int buttonIndex) ;
3132
Original file line number Diff line number Diff line change @@ -26,6 +26,7 @@ @implementation CustomIOSAlertView
2626@synthesize delegate;
2727@synthesize buttonTitles;
2828@synthesize useMotionEffects;
29+ @synthesize closeOnTouchUpOutside;
2930
3031- (id )initWithParentView : (UIView *)_parentView
3132{
@@ -45,6 +46,7 @@ - (id)init
4546
4647 delegate = self;
4748 useMotionEffects = false ;
49+ closeOnTouchUpOutside = false ;
4850 buttonTitles = @[@" Close" ];
4951
5052 [[UIDevice currentDevice ] beginGeneratingDeviceOrientationNotifications ];
@@ -445,4 +447,15 @@ - (void)keyboardWillHide: (NSNotification *)notification
445447 ];
446448}
447449
450+ - (void )touchesEnded : (NSSet <UITouch *> *)touches withEvent : (UIEvent *)event {
451+ if (!closeOnTouchUpOutside) {
452+ return ;
453+ }
454+
455+ UITouch *touch = [touches anyObject ];
456+ if ([touch.view isKindOfClass: [CustomIOSAlertView class ]]) {
457+ [self close ];
458+ }
459+ }
460+
448461@end
You can’t perform that action at this time.
0 commit comments