Search code examples
iphoneios5brightnesssettingsuiscreen

Set back UIScreen Brightness to user setting


in some of the views of my iPhone app I set the screen brightness pragmatically like:

  [[UIScreen mainScreen] setBrightness:1.0];

then on

-(void)viewWillDisappear:(BOOL)animated
 {
 }

I will like to set it back to its original value. To do this how do I get the current UIScreen brightness value before I set it to 1.

tanx


Solution

  • "brightness" is a property, so it has a corresponding accessor. So just use:

    CGFloat oldBrightness = [[UIScreen mainScreen] brightness];