views:

48

answers:

3

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

A: 

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.

dkk
I add this line of code : #import <GraphicsServices/GraphicsServices.h> and use GSEventSetBacklightLevel(newLevel); but can't find GraphicServices
SajjadZare
Isn't this something that would get your App rejected? I also remember reading it only worked in all versions before iPhone OS 3?
ing0
+1  A: 

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!

ing0
A: 

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