Newer iPhones have two LEDs: one basic white LED and an Amber LED for softer photography.
I'm trying to turn my iPhone into a flashlight but I want to get the maximal brightness. I've successfully been able to turn off and on the white LED with the code below, but I can't get the amber LED and the white LED to turn on at the same time.
Here's my function written in Swift:
func toggleTorch(on on: Bool) {
let device = AVCaptureDevice.defaultDeviceWithMediaType(AVMediaTypeVideo)
if device.hasTorch {
do {
try device.lockForConfiguration()
if on == true {
device.torchMode = .On
} else {
device.torchMode = .Off
}
device.unlockForConfiguration()
} catch {
print("Torch could not be used")
}
} else {
print("Torch is not available")
}
}