-(void)openFlashlight
{
AVCaptureDevice * device = [AVCaptureDevice defaultDeviceWithMediaType:AVMediaTypeVideo];
if (device.torchMode == AVCaptureTorchModeOff) {
[device lockForConfiguration:nil];
[device setTorchMode:AVCaptureTorchModeOn];
[device unlockForConfiguration];
[openFlashLightButton setTitle:@"关灯" forState:UIControlStateNormal];
}else{
[device lockForConfiguration:nil];
[device setTorchMode:AVCaptureTorchModeOff];
[device unlockForConfiguration];
[openFlashLightButton setTitle:@"开灯" forState:UIControlStateNormal];
}
}
iOS应用中打开 手电筒/闪光灯 的方法
最新推荐文章于 2020-05-12 13:48:53 发布