1

Is it possible to reduce light(brightness) of screen from code ?

SajjadZare
  • 2,487
  • 4
  • 38
  • 68
  • 1
    possible duplicate of [Change Backlight Brightness on iPhone Programmatically](http://stackoverflow.com/questions/366889/change-backlight-brightness-on-iphone-programmatically) – DarkDust Oct 22 '10 at 14:18

3 Answers3

1

What I did is add a UIView on top of everything in the MainViewController. I then set the UIView background colour to black and give it an alpha based on what you want it setting too. If you want to make the screen brighter you can add in the same thing with a white background.

Seems to work without annoying those Apple App Testers!

ingh.am
  • 25,981
  • 43
  • 130
  • 177
1

This is not a "published" API, therefore Apple will reject your sumbission from the App Store if you use it. So the short answer is "No".

However...

An effective technique that people use is to place a UIView over your main window, give it a solid black background, then adjust the opacity to darken what shows behind it. I've done this by doing the following:

In your appDelagate's "applicationDidFinishLaunching" call, where you would normally do:

[window addSubview:viewController.view];

Instead do:

[window addSubview:viewController.view];
[window addSubview:darkScreen];

Where "darkscreen" is an (IBOutlet) UIView created with Interface builder and in the MainWindow.xib as follows:

  1. Background is BLACK
  2. Alpha is 0
  3. User interaction is disabled

When you want to "dim" the screen, reference darkScreen from your appDelegate, and bump up it's Alpha.

Brad
  • 11,262
  • 8
  • 55
  • 74
  • P.S. I actually made a "redscreen" variant of this to give users a "night mode" for a marine charting app I wrote. Very effective, and it even works with all toolbars, subviews and stuff the viewController throws up. – Brad Aug 02 '11 at 17:17
0

See this post

Also, try if this still works for you:

GSEventSetBacklightLevel(newLevel); //The new level: 0.0 - 1.0.

In order for this to work, you will need to include GraphicsServices.h. Depending on where you get your headers, you may need to add the GSEventSetBacklightLevel(float value); method to the headers, else the method won't quite work.

Community
  • 1
  • 1
Daniel
  • 20,420
  • 10
  • 92
  • 149
  • I add this line of code : #import and use GSEventSetBacklightLevel(newLevel); but can't find GraphicServices – SajjadZare Oct 22 '10 at 14:32
  • 1
    Isn't this something that would get your App rejected? I also remember reading it only worked in all versions before iPhone OS 3? – ingh.am Oct 22 '10 at 15:45