//判断闪光灯状态,修改默认的"CameraFlashOff" 按钮图片。转由 TGCameraFlash.m 控制图标切换
AVCaptureDevice *device = [AVCaptureDevice defaultDeviceWithMediaType:AVMediaTypeVideo];
AVCaptureFlashMode mode = [device flashMode];
if ([device lockForConfiguration:nil]) {
switch ([device flashMode]) {
case AVCaptureFlashModeAuto:
mode = AVCaptureFlashModeOn;
break;
case AVCaptureFlashModeOn:
mode = AVCaptureFlashModeOff;
break;
case AVCaptureFlashModeOff:
mode = AVCaptureFlashModeAuto;
break;
}
if (device.autoFocusRangeRestrictionSupported) {
device.autoFocusRangeRestriction = AVCaptureAutoFocusRangeRestrictionNear;
}
if (device.smoothAutoFocusSupported) {
device.smoothAutoFocusEnabled = YES;
}
if([device isFocusModeSupported:AVCaptureFocusModeContinuousAutoFocus]){
device.focusMode = AVCaptureFocusModeContinuousAutoFocus;
}
device.exposureMode = AVCaptureExposureModeContinuousAutoExposure;
[device unlockForConfiguration];
}