在做扫码需求,往往会有放大镜头需求。
苹果提供了AVCaptureConnection中,videoScaleAndCropFactor:缩放裁剪系数,使用该属性,可以实现拉近拉远镜头。再结合手势UIPinchGestureRecognizer,就很简单实现手势拉近拉远镜头。
- 手势代码
///记录开始的缩放比例
@property(nonatomic,assign)CGFloat beginGestureScale;
///最后的缩放比例
@property(nonatomic,assign)CGFloat effectiveScale;
- (void)cameraInitOver
{
if (self.isVideoZoom) {
UIPinchGestureRecognizer *pinch = [[UIPinchGestu