iOS闪关灯的打开与关闭
2016-03-20 本文已影响65人
木语先生
//点击的按钮时要执行的方法
-(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];
}