美文网首页
iOS闪关灯的打开与关闭

iOS闪关灯的打开与关闭

作者: 木语先生 | 来源:发表于2016-03-20 17:58 被阅读65次
    //点击的按钮时要执行的方法
    -(void)ClickButton {  
        AVCaptureDevice *device = [AVCaptureDevice defaultDeviceWithMediaType:AVMediaTypeVideo];
        if ([device hasTorch] && [device hasFlash]) {
            [device lockForConfiguration:nil];
            } 
        if (device.torchMode == AVCaptureTorchModeOn) {
            [device setTorchMode:AVCaptureTorchModeOff];     
        }else{
            [device setTorchMode:AVCaptureTorchModeOn]; 
        }
        [device unlockForConfiguration];
    }
    

    相关文章

      网友评论

          本文标题:iOS闪关灯的打开与关闭

          本文链接:https://www.haomeiwen.com/subject/fvqklttx.html