Is there a method or property that allows you to set the brightness of the LED light on the iPhone 4?
-
If there is, it probably isn't public for use on the App Store. Apple is very guarded about letting you mess with their user experience. – iwasrobbed Jul 01 '10 at 03:18
-
well there's a way to change the brightness of the front screen right? i guess that's easier though since you can just display an off white image... – marty Jul 01 '10 at 03:25
-
Well, people give the illusion of changing the brightness by either using an off-white background or messing with the alpha channel, but you can't actually change any of the hardware settings which affect brightness. – iwasrobbed Jul 01 '10 at 04:19
3 Answers
There is a brightness method available for iOS 6 and later.
[AVCaptureDevice setTorchModeOnWithLevel:1.0 error:&error];
The 'level' is a float from 0 to ~1, AVCaptureMaxAvailableTorchLevel
. Fluctuating this will allow us to modify brightness.

- 13,441
- 3
- 48
- 75
In principle, brightness can be varied using a PWM (pulse width modulation) technique: For example, for 50% brightness, turn the LED on for some period of time, then turn it off for the same period of time, and so on and so on. If performed fast enough, no flicker will be seen, and brightness will appear to be 50%.
Unfortunately, I have not found a way to toggle the iPhone's LED at a high enough frequency, yet. Toggling AVCaptureTorchModeOn
/ AVCaptureTorchModeOff
does not appear to be fast enough - or maybe the main thread (on which I tried) just has a too low priority in iOS.
Edit: There now is an API for setting the torch level in iOS 6.

- 384
- 2
- 12
The LED light intensity never seems to vary when using it as a camera flash no matter what the external lighting conditions, so I speculate that the hardware only supports a fixed on/off switch for the light with a constant brightness.
If there is a way to alter the brightness, at the moment it is not exposed via any public API.

- 2,296
- 1
- 22
- 39