引入
#import <AVFoundation/AVFoundation.h>
打开闪光灯
AVCaptureDevice *device = [AVCaptureDevice defaultDeviceWithMediaType:AVMediaTypeVideo]; if (![device hasTorch]) {//判断是否有闪光灯 NSLog(@"no torch"); }else{ [device lockForConfiguration:nil];//锁定闪光灯 [device setTorchMode: AVCaptureTorchModeOn];//打开闪光灯 [device unlockForConfiguration]; //解除锁定 }
关闭闪光灯
[device setTorchMode: AVCaptureTorchModeOff];
时间: 2024-12-20 17:39:28