iOS调用闪光灯的代码

jopen 11年前

1、导入相应的库文件AVFoundation

2、   

    AVCaptureDevice *device = [AVCaptureDevice defaultDeviceWithMediaType:AVMediaTypeVideo];            if (![device hasTorch]) {                NSLog(@"no torch");            }else{                [device lockForConfiguration:nil];                if (!on) {                    [device setTorchMode: AVCaptureTorchModeOn];                }                else                {                    [device setTorchMode: AVCaptureTorchModeOff];                }                                [device unlockForConfiguration];            }