Question

Does the SDK provide any way to change the brightness of the backlight, or turn it off temporarily?

Was it helpful?

Solution

No. This is not available in the SDK. If it's something you think would be useful, I suggest you file an enhancement request.

OTHER TIPS

I'm trying to do the same thing. As it happens there are a number posts out there in the internets with "solutions" for this.

The most detailed is here This one is more succinct

The problem is that I've tried these and they all rely on calling this function

GSEventSetBacklightLevel();

which requires this header to be imported

#import <GraphicsServices/GraphicsServices.h>

And that import fails in the SDK reporting that the header file cannot be found.

I've searched for some solution but haven't found it. There is some talk about "building the toolchain" (for the best description I've found see here) but that seems to involve bypassing the SDK altogether. Pretty drastic.

Summary: It's possible, but not with the standard iPhone SDK. I imagine an update to the SDK will come soon that should allow for it.

Let me know if you find any other solution.

-(void)changeLight{

    GSEventSetBacklightLevel(float number);//number between 0.0 - 1.0
}

call the above method using

[self performSelector:@selector(changeLight) withObject:nil afterDelay:0.0];

you can add the private framework by just drag and drop to your xcode project from /Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS4.2.sdk/System/Library/PrivateFrameworks/GraphicsServices.framework.

Also add #import "GraphicsServices.h" header in your .h file..remember: since you are using private framework you application will reject in app store push

In my SDK (5.0.1) it seems that "GraphicsServices.h" is no longer there, but you can declare it yourself like this:

void GSEventSetBacklightLevel(float level);

Note that the linker will complain, unless you include the framework GraphicsServices.framework in your project.

About your question about turning the backlight off, I found out that you can do it by passing a very large negative number to GSEventSetBacklightLevel, like this:

GSEventSetBacklightLevel(-INFINITY);

In my tests this will completely black out the screen.

Remember that this might still cause burn-in in the LCD pixels if you display static graphics, even when the backlight is off. And that this call will cause rejection if submitteed to app store.

try this code. i hope it helps...

//in viewWillAppear

float prevBrightnessLevel = [UIScreen mainScreen].brightness;

[UIScreen mainScreen].brightness = 1.0;

//in viewWillDisappear

[UIScreen mainScreen].brightness = prevBrightnessLevel;

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top