IPhone 设备状态、闪光灯状态

 

//判断闪光灯状态,修改默认的"CameraFlashOff" 按钮图片。转由 TGCameraFlash.m 控制图标切换
    AVCaptureDevice *device = [AVCaptureDevice defaultDeviceWithMediaType:AVMediaTypeVideo];
    AVCaptureFlashMode mode = [device flashMode];
    if ([device lockForConfiguration:nil]) {
        
        switch ([device flashMode]) {
            case AVCaptureFlashModeAuto:
                mode = AVCaptureFlashModeOn;
                break;
                
            case AVCaptureFlashModeOn:
                mode = AVCaptureFlashModeOff;
                break;
                
            case AVCaptureFlashModeOff:
                mode = AVCaptureFlashModeAuto;
                break;
        }

        
        if (device.autoFocusRangeRestrictionSupported) {
            device.autoFocusRangeRestriction = AVCaptureAutoFocusRangeRestrictionNear;
        }
        
        if (device.smoothAutoFocusSupported) {
            device.smoothAutoFocusEnabled = YES;
        }
        
        if([device isFocusModeSupported:AVCaptureFocusModeContinuousAutoFocus]){
            device.focusMode = AVCaptureFocusModeContinuousAutoFocus;
        }
        
        device.exposureMode = AVCaptureExposureModeContinuousAutoExposure;
        
        [device unlockForConfiguration];
    }

posted on 2014-12-31 10:17  奋进的闹钟  阅读(469)  评论(0编辑  收藏  举报

导航