#import <AVFoundation/AVFoundation.h>
@property (nonatomic,strong) AVCaptureDevice *device;
-(void)Open:(UIButton *)sender{
sender.selected=!sender.selected;
self.device = [AVCaptureDevice defaultDeviceWithMediaType:AVMediaTypeVideo];
[self.device lockForConfiguration:nil];
if ([self.device hasFlash]) {
if(_device.torchMode==AVCaptureFlashModeOff) {
_device.torchMode=AVCaptureTorchModeOn;
}else if(_device.torchMode==AVCaptureFlashModeOn) {
_device.torchMode=AVCaptureTorchModeOff;
}
}
[self.device unlockForConfiguration];
}