diff --git a/LLSimpleCamera/LLSimpleCamera.h b/LLSimpleCamera/LLSimpleCamera.h index 4e9f9f5..5e438a9 100644 --- a/LLSimpleCamera/LLSimpleCamera.h +++ b/LLSimpleCamera/LLSimpleCamera.h @@ -215,6 +215,13 @@ typedef enum : NSUInteger { */ - (void)alterFocusBox:(CALayer *)layer animation:(CAAnimation *)animation; +/** + * Function to zoom the camera from code + * + * @param factor from 0.0 to 1.0 + */ +- (void) scaleToFactor:(CGFloat)factor; + /** * Checks is the front camera is available. */ @@ -224,4 +231,8 @@ typedef enum : NSUInteger { * Checks is the rear camera is available. */ + (BOOL)isRearCameraAvailable; + + + + @end diff --git a/LLSimpleCamera/LLSimpleCamera.m b/LLSimpleCamera/LLSimpleCamera.m index db75c9f..28600c9 100644 --- a/LLSimpleCamera/LLSimpleCamera.m +++ b/LLSimpleCamera/LLSimpleCamera.m @@ -150,6 +150,18 @@ - (void)handlePinchGesture:(UIPinchGestureRecognizer *)recognizer } } +#pragma mark - Zooming programmatically +- (void) scaleToFactor:(CGFloat)factor +{ + NSError *error = nil; + if ([self.videoCaptureDevice lockForConfiguration:&error]) + { + [self.videoCaptureDevice rampToVideoZoomFactor:factor withRate:10]; + + [self.videoCaptureDevice unlockForConfiguration]; + } +} + #pragma mark - Camera - (void)attachToViewController:(UIViewController *)vc withFrame:(CGRect)frame