Adjust the brightness of the screen through code
Asked Answered
T

3

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.

Tani answered 25/10, 2011 at 18:43 Comment(0)
S
16

You can use:

[[UIScreen mainScreen] setBrightness:1.0];

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

Silber answered 25/10, 2011 at 19:3 Comment(1)
then how to implement this in ios 4,Can you give any idea please...ThanksEldred
O
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.

Ophthalmologist answered 25/10, 2011 at 22:58 Comment(0)
L
0

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

Lactone answered 25/10, 2011 at 19:3 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.