Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Adjust the brightness of the screen through code

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.

like image 344
Sid Avatar asked Oct 25 '11 18:10

Sid


2 Answers

You can use:

[[UIScreen mainScreen] setBrightness:1.0];

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

like image 188
NJones Avatar answered Sep 22 '22 20:09

NJones


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.

like image 23
Stavash Avatar answered Sep 20 '22 20:09

Stavash