From 834443b69602339311bef9073d597c64517fedf6 Mon Sep 17 00:00:00 2001 From: Luis Fernando Mata Date: Fri, 9 Dec 2016 12:37:45 +0800 Subject: [PATCH 1/2] Added custom tap to focus --- LLSimpleCamera/LLSimpleCamera.h | 5 +++++ LLSimpleCamera/LLSimpleCamera.m | 8 ++++++++ 2 files changed, 13 insertions(+) diff --git a/LLSimpleCamera/LLSimpleCamera.h b/LLSimpleCamera/LLSimpleCamera.h index 4e9f9f5..8ccc549 100644 --- a/LLSimpleCamera/LLSimpleCamera.h +++ b/LLSimpleCamera/LLSimpleCamera.h @@ -215,6 +215,11 @@ typedef enum : NSUInteger { */ - (void)alterFocusBox:(CALayer *)layer animation:(CAAnimation *)animation; +/** + * Call this method in case you need to implement a custom tap to focus gesture + */ +- (void) focusViewOnPoint: (CGPoint) point; + /** * Checks is the front camera is available. */ diff --git a/LLSimpleCamera/LLSimpleCamera.m b/LLSimpleCamera/LLSimpleCamera.m index db75c9f..4c1d5dd 100644 --- a/LLSimpleCamera/LLSimpleCamera.m +++ b/LLSimpleCamera/LLSimpleCamera.m @@ -749,6 +749,14 @@ - (void)showFocusBox:(CGPoint)point } } +- (void) focusViewOnPoint: (CGPoint) point { + if (!self.tapToFocus) { + return; + } + + [self showFocusBox:point]; +} + #pragma mark - UIViewController - (void)viewWillAppear:(BOOL)animated From 99db6edcf29b67085e759019582dd87e73f91f77 Mon Sep 17 00:00:00 2001 From: Luis Fernando Mata Date: Fri, 9 Dec 2016 14:55:48 +0800 Subject: [PATCH 2/2] Added gesture recognizer and test if point is inside preview view before sending the action --- LLSimpleCamera/LLSimpleCamera.h | 2 +- LLSimpleCamera/LLSimpleCamera.m | 10 +++++----- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/LLSimpleCamera/LLSimpleCamera.h b/LLSimpleCamera/LLSimpleCamera.h index 8ccc549..0a02102 100644 --- a/LLSimpleCamera/LLSimpleCamera.h +++ b/LLSimpleCamera/LLSimpleCamera.h @@ -218,7 +218,7 @@ typedef enum : NSUInteger { /** * Call this method in case you need to implement a custom tap to focus gesture */ -- (void) focusViewOnPoint: (CGPoint) point; +- (void) focusViewWithGesture: (UITapGestureRecognizer *) gesture; /** * Checks is the front camera is available. diff --git a/LLSimpleCamera/LLSimpleCamera.m b/LLSimpleCamera/LLSimpleCamera.m index 4c1d5dd..b8956c2 100644 --- a/LLSimpleCamera/LLSimpleCamera.m +++ b/LLSimpleCamera/LLSimpleCamera.m @@ -749,12 +749,12 @@ - (void)showFocusBox:(CGPoint)point } } -- (void) focusViewOnPoint: (CGPoint) point { - if (!self.tapToFocus) { - return; - } +- (void) focusViewWithGesture: (UITapGestureRecognizer *) gesture { + CGPoint touchedPoint = [gesture locationInView:self.view]; - [self showFocusBox:point]; + if (CGRectContainsPoint(self.view.frame, touchedPoint)) { + [self previewTapped:gesture]; + } } #pragma mark - UIViewController