闪光灯


func toggleFlash()
{
let captureDevice1 = AVCaptureDevice.defaultDeviceWithMediaType(AVMediaTypeVideo)
if(captureDevice1.hasFlash)
{
do {
try captureDevice1.lockForConfiguration()
} catch
{
print("lockForConfiguration error")
}
if( captureDevice1.torchMode == AVCaptureTorchMode.On)
{
captureDevice1.torchMode = AVCaptureTorchMode.Off
}else
{
do {
try captureDevice1.setTorchModeOnWithLevel(1.0)
}catch
{
print("setTorchModeOnWithLevel error")
}
}
captureDevice1.unlockForConfiguration()
}
}

你可能感兴趣的:(闪光灯)