iOS應用中開啟 手電筒/閃光燈 的方法
阿新 • • 發佈:2019-02-07
-(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]; } }