Reputation: 6560
Is there a way to specify to the device that when one sets setTorchModeOnWithLevel
that they would activate the Retina Flash (iPhone6s/7's front facing flash) instead of the back True-Tone LED Flash?
The following standard code appears to only be able to activate the rear LED:
AVCaptureDevice.defaultDevice(withDeviceType: AVCaptureDeviceType.builtInDualCamera,
mediaType: AVMediaTypeVideo, position: .front)
try device.lockForConfiguration();
let torchOn = !device.isTorchActive;
try device.setTorchModeOnWithLevel(1.0);
device.unlockForConfiguration();
Does an API exist within iOS for one to have access to the Retina Flash?
Upvotes: 2
Views: 816
Reputation: 3488
AFAIK iOS DON'T have any API specific to Retina Flash. (as of dated iOS 10.2)
From Apple developer thread
Retina Flash iPhone 6s and 6s Plus contain a custom display chip that allows the retina display to briefly flash 3 times brighter than its usual maximum illuminance. No new API was added to support this feature. Since iOS 4, AVCaptureDevice has supported the
-hasFlash
,-isFlashModeSupported:
and-flashMode
properties. The iPhone 6s and 6s Plus front-facing cameras are the first front-facing iOS cameras to respond YES to the-hasFlash
property. By setting the front-facing camera's flashMode toAVCaptureFlashModeOn
orAVCaptureFlashModeAuto
, the retina flash fires when a still image is captured (seeAVCaptureStillImageOutput’s captureStillImageAsynchronouslyFromConnection:completionHandler:
), just as the True Tone flash fires for rear-facing camera stills.
So to make your code to work check -hasFlash
and then set the Flash mode to auto or on.
Upvotes: 4