iOS 10.2 - 激活 Retina 闪光灯而不是带有手电筒的背面 LED
iOS 10.2 - Activate Retina Flash instead of Back LED with Torch
有没有一种方法可以让设备在设置 setTorchModeOnWithLevel
时激活 Retina 闪光灯(iPhone6s/7 的正面闪光灯)而不是背面的 True-Tone LED闪光灯?
以下标准代码似乎只能激活后部 LED:
AVCaptureDevice.defaultDevice(withDeviceType: AVCaptureDeviceType.builtInDualCamera,
mediaType: AVMediaTypeVideo, position: .front)
try device.lockForConfiguration();
let torchOn = !device.isTorchActive;
try device.setTorchModeOnWithLevel(1.0);
device.unlockForConfiguration();
iOS 中是否存在 API 以便可以访问 Retina Flash?
AFAIK iOS 不要 有任何 API 特定于 Retina Flash。 (截至日期 iOS 10.2)
来自 Apple 开发者 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 to AVCaptureFlashModeOn
or
AVCaptureFlashModeAuto
, the retina flash fires when a still image is
captured (see AVCaptureStillImageOutput’s
captureStillImageAsynchronouslyFromConnection:completionHandler:
),
just as the True Tone flash fires for rear-facing camera stills.
因此,要使您的代码正常工作,请检查 -hasFlash
,然后将 Flash 模式设置为自动或开启。
有没有一种方法可以让设备在设置 setTorchModeOnWithLevel
时激活 Retina 闪光灯(iPhone6s/7 的正面闪光灯)而不是背面的 True-Tone LED闪光灯?
以下标准代码似乎只能激活后部 LED:
AVCaptureDevice.defaultDevice(withDeviceType: AVCaptureDeviceType.builtInDualCamera,
mediaType: AVMediaTypeVideo, position: .front)
try device.lockForConfiguration();
let torchOn = !device.isTorchActive;
try device.setTorchModeOnWithLevel(1.0);
device.unlockForConfiguration();
iOS 中是否存在 API 以便可以访问 Retina Flash?
AFAIK iOS 不要 有任何 API 特定于 Retina Flash。 (截至日期 iOS 10.2)
来自 Apple 开发者 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.
因此,要使您的代码正常工作,请检查 -hasFlash
,然后将 Flash 模式设置为自动或开启。