//点击的按钮时要执行的方法
-(void)ClickButton {
AVCaptureDevice *device = [AVCaptureDevice defaultDeviceWithMediaType:AVMediaTypeVideo];
if ([device hasTorch] && [device hasFlash]) {
[device lockForConfiguration:nil];
}
if (device.torchMode == AVCaptureTorchModeOn) {
[device setTorchMode:AVCaptureTorchModeOff];
}else{
[device setTorchMode:AVCaptureTorchModeOn];
}
[device unlockForConfiguration];
}
网友评论