1

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")
        }
    }
mrry
  • 125,488
  • 26
  • 399
  • 400
law
  • 21
  • 3
  • FYI the flashlight functionality is available in iOS out of the box. – MirekE Dec 23 '15 at 02:27
  • I'm trying to turn on both LEDs programmatically at specific times during the running of my app. I can easily turn on the white LED, but I'm not sure how to access the second amber LED. – law Dec 29 '15 at 04:37
  • Possible duplicate of [Individual Access of Camera LED Lights of iPhone 5s](https://stackoverflow.com/questions/19275929/individual-access-of-camera-led-lights-of-iphone-5s) – Senseful Jul 03 '17 at 17:21

0 Answers0