From 91c7e914794119493e10286ce35847a6c77a61cf Mon Sep 17 00:00:00 2001 From: Thinh Date: Fri, 4 Sep 2015 07:18:48 +0700 Subject: [PATCH] tap guesture and swipe down guesture to close view --- UIViewController+KeyboardAnimation.m | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/UIViewController+KeyboardAnimation.m b/UIViewController+KeyboardAnimation.m index 18d5c53..0f4c089 100644 --- a/UIViewController+KeyboardAnimation.m +++ b/UIViewController+KeyboardAnimation.m @@ -34,6 +34,15 @@ @implementation UIViewController (KeyboardAnimation) - (void)an_subscribeKeyboardWithAnimations:(ANAnimationsWithKeyboardBlock)animations completion:(ANCompletionKeyboardAnimations)completion { [self an_subscribeKeyboardWithBeforeAnimations:nil animations:animations completion:completion]; + //tap guesture and swipe down guesture to close view + [self.view addGestureRecognizer:[[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(hideKeyboard)]]; + UISwipeGestureRecognizer *swipeDown = [[UISwipeGestureRecognizer alloc] initWithTarget:self action:@selector(hideKeyboard)]; + [swipeDown setDirection:UISwipeGestureRecognizerDirectionDown]; + [self.view addGestureRecognizer:swipeDown]; +} + +- (void) hideKeyboard{ + [self.view endEditing:true]; } - (void)an_subscribeKeyboardWithBeforeAnimations:(ANBeforeAnimationsWithKeyboardBlock)beforeAnimations