如何锁定AVfoundation中的白平衡以获得快速?

时间:2015-04-28 01:45:31

标签: swift avfoundation

我正在尝试锁定我的iPhone,使相机的白平衡恢复到当前状态,但是从将Objective-c代码转换为swift方面我遇到了麻烦。这是objective-c中的代码:

[device setWhiteBalanceMode:AVCaptureWhiteBalanceModeLocked];

这就是我认为swift中的代码应该是这样的:

captureDevice.setWhiteBalanceMode(AVCaptureWhiteBalanceMode.Locked)

和Xcode告诉我:

'AVCaptureDevice' does not have a member named 'setWhiteBalanceMode'

1 个答案:

答案 0 :(得分:4)

        if captureDevice.lockForConfiguration(nil) {
            var gains: AVCaptureWhiteBalanceGains = AVCaptureWhiteBalanceGainsCurrent
            captureDevice.setWhiteBalanceModeLockedWithDeviceWhiteBalanceGains(gains, completionHandler:nil);
            captureDevice.unlockForConfiguration()
        }