我正在尝试锁定我的iPhone,使相机的白平衡恢复到当前状态,但是从将Objective-c代码转换为swift方面我遇到了麻烦。这是objective-c中的代码:
[device setWhiteBalanceMode:AVCaptureWhiteBalanceModeLocked];
这就是我认为swift中的代码应该是这样的:
captureDevice.setWhiteBalanceMode(AVCaptureWhiteBalanceMode.Locked)
和Xcode告诉我:
'AVCaptureDevice' does not have a member named 'setWhiteBalanceMode'
答案 0 :(得分:4)
if captureDevice.lockForConfiguration(nil) {
var gains: AVCaptureWhiteBalanceGains = AVCaptureWhiteBalanceGainsCurrent
captureDevice.setWhiteBalanceModeLockedWithDeviceWhiteBalanceGains(gains, completionHandler:nil);
captureDevice.unlockForConfiguration()
}