Skip to content

Commit

Permalink
Merge branch 'master' of github.com:wimagguc/ios-custom-alertview
Browse files Browse the repository at this point in the history
  • Loading branch information
wimagguc committed Sep 7, 2016
2 parents ed84129 + eff5bd4 commit 5bf1b3f
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@
@property (nonatomic, assign) id<CustomIOSAlertViewDelegate> delegate;
@property (nonatomic, retain) NSArray *buttonTitles;
@property (nonatomic, assign) BOOL useMotionEffects;
@property (nonatomic, assign) BOOL closeOnTouchUpOutside; // Closes the AlertView when finger is lifted outside the bounds.

@property (copy) void (^onButtonTouchUpInside)(CustomIOSAlertView *alertView, int buttonIndex) ;

Expand Down
13 changes: 13 additions & 0 deletions CustomIOSAlertView/CustomIOSAlertView/View/CustomIOSAlertView.m
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ @implementation CustomIOSAlertView
@synthesize delegate;
@synthesize buttonTitles;
@synthesize useMotionEffects;
@synthesize closeOnTouchUpOutside;

- (id)initWithParentView: (UIView *)_parentView
{
Expand All @@ -45,6 +46,7 @@ - (id)init

delegate = self;
useMotionEffects = false;
closeOnTouchUpOutside = false;
buttonTitles = @[@"Close"];

[[UIDevice currentDevice] beginGeneratingDeviceOrientationNotifications];
Expand Down Expand Up @@ -445,4 +447,15 @@ - (void)keyboardWillHide: (NSNotification *)notification
];
}

- (void)touchesEnded:(NSSet<UITouch *> *)touches withEvent:(UIEvent *)event {
if (!closeOnTouchUpOutside) {
return;
}

UITouch *touch = [touches anyObject];
if ([touch.view isKindOfClass:[CustomIOSAlertView class]]) {
[self close];
}
}

@end

0 comments on commit 5bf1b3f

Please sign in to comment.