Is it possible to reduce light(brightness) of screen f开发者_运维知识库rom code ?
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:
- Background is BLACK
- Alpha is 0
- User interaction is disabled
When you want to "dim" the screen, reference darkScreen from your appDelegate, and bump up it's Alpha.
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!
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.
精彩评论