March5,2008
4.09 PM
Permalink

Change backlight brightness on iPhone

  1. Get the current backlight value stored in Settings
     NSNumber *bl = (NSNumber*) CFPreferencesCopyAppValue(CFSTR("SBBacklightLevel"), CFSTR("com.apple.springboard"));
    prevBacklightLevel = [bl floatValue];
  2. Set our new value
    GSEventSetBacklightLevel(1.0f); // from 0.0 (off) to 1.0 (max)
  3. Then restore the previous brightness
    - (void)applicationWillTerminate
    {
    GSEventSetBacklightLevel(prevBacklightLevel);
    }
Comments (View)
Page 1 of 1