禁用最大缩放

时间:2015-11-01 15:44:06

标签: ios swift avcapturesession

我正在制作相机,它有一个缩放的缩放。我试图找到一种方法来禁用最大缩放级别。这是我的代码......

func pinch(pinch: UIPinchGestureRecognizer) {
    let device = AVCaptureDevice.defaultDeviceWithMediaType(AVMediaTypeVideo)

    let pinchVelocityDividerFactor:CGFloat = 10

    if pinch.state == UIGestureRecognizerState.Changed {
        do {
            try device.lockForConfiguration()

            let desiredZoomFactor = device.videoZoomFactor + atan2(pinch.velocity, pinchVelocityDividerFactor)

            device.videoZoomFactor = max(1, min(desiredZoomFactor, device.activeFormat.videoMaxZoomFactor))

            device.unlockForConfiguration()

        } catch {
            // handle error
            return
        }
    }
}

有没有我的相机没有像Snapchat这样的最大变焦?谢谢!

0 个答案:

没有答案