IOS-闪光灯操作

35 篇文章 0 订阅
AVCaptureDevice.h主要用来获取iphone一些关于相机设备的属性。
前置和后置摄像头

enum {

AVCaptureDevicePositionBack                = 1,

AVCaptureDevicePositionFront               = 2

};

typedef NSInteger AVCaptureDevicePosition;


闪光灯开关

 

enum {

AVCaptureFlashModeOff  = 0,

AVCaptureFlashModeOn   = 1,

AVCaptureFlashModeAuto = 2

};

typedef NSInteger AVCaptureFlashMode;


手电筒开关

 

enum {

AVCaptureTorchModeOff  = 0,

AVCaptureTorchModeOn   = 1,

AVCaptureTorchModeAuto = 2,

};

typedef NSInteger AVCaptureTorchMode;


焦距调整

 

enum {

AVCaptureFocusModeLocked              = 0,

AVCaptureFocusModeAutoFocus           = 1,

AVCaptureFocusModeContinuousAutoFocus = 2,

};

typedef NSInteger AVCaptureFocusMode;


曝光量调节

 

enum {

AVCaptureExposureModeLocked = 0,

AVCaptureExposureModeAutoExpose = 1,

AVCaptureExposureModeContinuousAutoExposure = 2,

};

typedef NSInteger AVCaptureExposureMode;


白平衡

 

enum {

AVCaptureWhiteBalanceModeLocked         = 0,

AVCaptureWhiteBalanceModeAutoWhiteBalance         = 1,

    AVCaptureWhiteBalanceModeContinuousAutoWhiteBalance = 2,

};

typedef NSInteger AVCaptureWhiteBalanceMode;


 

开启闪光灯
AVCaptureDevice* d = nil; // find a device by positionNSArray* allDevices = [AVCaptureDevice devices]; for (AVCaptureDevice* currentDevice in allDevices) {   if (currentDevice.position == AVCaptureDevicePositionBack) {     d = currentDevice;   } } // at this point, d may still be nil, assuming we found something we like.... NSError* err = nil; BOOL lockAcquired = [d lockForConfiguration:&err]; if (!lockAcquired) {    // log err and handle... } else {   // flip on the flash mode    if ([d hasFlash] && [d isFlashModeSupported:AVCaptureFlashModeOn] ) {       [d setFlashMode:AVCaptureFlashModeOn];    }    [d unlockForConfiguration]; }
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值