iOS - 开启手电筒
//点击手电筒
- (void)clickFlashLight:(UIButton*)btn{
btn.selected=!btn.selected;
AVCaptureDevice *device =[AVCaptureDevicedefaultDeviceWithMediaType:AVMediaTypeVideo];
//修改前必须先锁定
[self.devicelockForConfiguration:nil];
//必须判定是否有闪光灯,否则如果没有闪光灯会崩溃
if([self.devicehasFlash]) {
if(device.torchMode==AVCaptureFlashModeOff) {
device.torchMode=AVCaptureTorchModeOn;
}else if(device.torchMode==AVCaptureFlashModeOn) {
device.torchMode=AVCaptureTorchModeOff;
}
}
[self.deviceunlockForConfiguration];
}
本文标题:iOS - 开启手电筒
本文链接:https://www.haomeiwen.com/subject/xfzdnhtx.html
网友评论