8

I am developing an iPhone application and I need to adjust the brightness of the screen through my application, in the same way as we do through the Settings app.

I have searched but have not found a solution.

jscs
  • 63,694
  • 13
  • 151
  • 195
Sid
  • 407
  • 1
  • 9
  • 17

3 Answers3

16

You can use:

[[UIScreen mainScreen] setBrightness:1.0];

But only on iOS 5. Not supported on earlier iOS versions.

NJones
  • 27,139
  • 8
  • 70
  • 88
2

If you require compatibility with older iOS versions, try a black overlay on top of your application's main window with partial alpha. I used it in an iPad app - only downside is that it won't darken elements like popovers.

Stavash
  • 14,244
  • 5
  • 52
  • 80
0

Check out the brightness property of UIScreen. This is a new API in iOS 5. You can't do it in older versions.

rob mayoff
  • 375,296
  • 67
  • 796
  • 848