42

I have an iPhone app for photographic purposes (kind of a lightbox). This app needs as much brightness as possible. Is there a way to change the screen brightness programmatically, and then restore it back some time later?

openfrog
  • 40,201
  • 65
  • 225
  • 373

3 Answers3

78

Edit: iOS 5 now includes a screen brightness API.

[[UIScreen mainScreen] setBrightness:0.5];

Previous answer:

No, this capability is not exposed via public APIS.

Edit: Note that a future possible iOS release may or may not have screen brightness on the multitasking bar on one particular iDevice.

Alastair Stuart
  • 4,165
  • 3
  • 36
  • 33
  • While I too can't say whether that is the case or not due to a certain agreement I have regarding the disclosure of proprietary information... it is certainly the case that the major third-party "reader" apps contain brightness sliders. So whether or not it's exposed, people are doing it, and it's flying with the app store reviewers. – Dan Ray Sep 23 '10 at 19:48
  • 5
    They're adjusting the colours of the background of the text, not the actual screen brightness. – Alastair Stuart Sep 24 '10 at 08:25
  • 9
    Kudos to you for coming back to your answer a year later and updating it :) – Sid Nov 15 '11 at 22:11
  • Any way to automatically unset the screen brightness? (revert to user's previous settings?) Or do I just have to keep track of that? – Andrew K Jun 13 '17 at 01:30
5

Here's a Swift answer to this question.

import UIKit
extension UIScreen
{
    static func setMainBrightness(brightness: CGFloat)
    {
        guard (0...1).contains(brightness) else
        {
            print("Attempt to set the screen brightness to an invalid value: \(brightness) should be between 0 and 1 inclusive.")
            return
        }
        self.main.brightness = brightness
    }
}

Call it by using:

UIScreen.setMainBrightness(0.5)

Or ignore my extension (which I just wrote to illustrate the limits) and just call:

UIScreen.main.brightness = 0.5
Glenn Howes
  • 5,447
  • 2
  • 25
  • 29
5

It is possible, but your app will most likely get rejected from the App Store, because it uses a private API. A flashlight-app was rejected because it adjusted the screen brightness, so I wouldn't recommend it.

In iOS 4.2, the iPad will have a screen brightness-adjuster in the multitasking-bar,

(as mentioned by @coob) so you could tell your users to set the brightness there.


What you could do, is to create a black overlay-view, and set it's alpha to more or less, according to how bright you want the screen to be. This won't actually make the screen less/more bright, but it will give the user an illusion of that.

Emil
  • 7,220
  • 17
  • 76
  • 135