我正试图将我的iphone背面摄像头的白平衡锁定到当前状态,但从将objective-c代码转换为swift的角度来看,我遇到了麻烦。这是objective-c中的代码:

[device setWhiteBalanceMode:AVCaptureWhiteBalanceModeLocked];

我认为swift中的代码应该是这样的:
captureDevice.setWhiteBalanceMode(AVCaptureWhiteBalanceMode.Locked)

Xcode告诉我:
'AVCaptureDevice' does not have a member named 'setWhiteBalanceMode'

最佳答案

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

10-08 05:58