#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];
原文地址:http://blog.csdn.net/cerastes/article/details/37740611