iOS 手电筒

版权声明:本文为博主原创文章,未经博主允许不得转载。



先导入AVFoundation.framework框架

#import <AVFoundation/AVFoundation.h>

-(void) turnOnAndturnOff:(bool)isBool


{    

    AVCaptureDevice *captureDevice = [AVCaptureDevice defaultDeviceWithMediaType:AVMediaTypeVideo];

    

    if ([captureDevice hasTorch]) {

        

        [captureDevice lockForConfiguration:nil];

        

        [captureDevice setTorchMode: AVCaptureTorchModeOn];//开灯

//      [device setTorchMode: AVCaptureTorchModeOff];//关灯

        

        [captureDevice unlockForConfiguration];       

    }       

}



转载请注明出处:http://blog.csdn.net/sevenquan


你可能感兴趣的:(ios,ios,手电筒,手电筒,手电灯)