0

Possible Duplicate:
Is there a way of adjusting the screen brightness programmatically?

i am new to stake over flow and its my first question in this forum. i am research many times but i cant get proper answer for this question.

I want to put one slider in my applications is for iphone and for ipad both which slider adjust the iphone brightness . means increase and decrease the iphone brightness.

so how can it be possible this through programmatically. i just want some idea that is it possible or not and how.

give me guidance as i am new to stake over flow.

Thanks

Community
  • 1
  • 1
  • 1
    This has been answered previously on Stack Overflow: http://stackoverflow.com/questions/3779667/is-there-a-way-of-adjusting-the-screen-brightness-programmatically – jonkroll Aug 19 '12 at 06:53

1 Answers1

7

refer a following code.

- (void)viewDidLoad
{
    UISlider *slider = [[UISlider alloc] initWithFrame:CGRectMake(0,0,300,40)];
    [slider addTarget:self action:@selector(sliderHandler:) forControlEvents:UIControlEventValueChanged];
    slider.minimumValue = 0.f;
    slider.maximumValue = 1.0f;
    slider.value = [[UIScreen mainScreen] brightness];
    [[self view]addSubview:slider];

    [super viewDidLoad];
}

- (void)sliderHandler:(UISlider *)sender
{
    //NSLog(@"value:%f", sender.value);
    [[UIScreen mainScreen] setBrightness:sender.value];
}
bitmapdata.com
  • 9,572
  • 5
  • 35
  • 43