2015-10-13 55 views
2

iOS 8 Camara功能可在輕按camara時調節亮度。如何在自定義相機上使用UISlider調整亮度?

enter image description here

我自己也嘗試這種代碼,但不工作。

AVCaptureDevice *device =[AVCaptureDevice defaultDeviceWithMediaType:AVMediaTypeVideo]; 

    AVCaptureWhiteBalanceGains deviceWhiteBalance;// = [device deviceWhiteBalanceGains]; 

AVCaptureWhiteBalanceTemperatureAndTintValues tempAndTint = [device temperatureAndTintValuesForDeviceWhiteBalanceGains:[device deviceWhiteBalanceGains]]; 

tempAndTint.temperature = (slider.value*100)*10000/100; 
if (slider.value < 0.50) { 
    tempAndTint.tint = -(slider.value*100)*150/100; 
} 
else{ 
    tempAndTint.tint = (slider.value*100)*150/100; 
} 


deviceWhiteBalance = [device deviceWhiteBalanceGainsForTemperatureAndTintValues:tempAndTint]; 
[device chromaticityValuesForDeviceWhiteBalanceGains:deviceWhiteBalance]; 


dispatch_async(dispatch_get_main_queue(), ^{ 

    AVCaptureDevice *device =[AVCaptureDevice defaultDeviceWithMediaType:AVMediaTypeVideo]; 
    if (device) { 
     [device setWhiteBalanceModeLockedWithDeviceWhiteBalanceGains:deviceWhiteBalance completionHandler:^(CMTime syncTime) { 

     }]; 
    } 
}); 
+0

的每一個新變化,我認爲它的曝光,而不是亮度。 –

回答

相關問題