How do we change the iPhone lighting through UISlider?
-
How to change the iPhone illumination by
UISlider
?
-
Create a slider:
UISlider *slider = [[UISlider alloc] initWithFrame:CGRectMake(0, 100, 320, 100)]; [slider addTarget:self action:@selector(changeBrightness:) forControlEvents:UIControlEventValueChanged]; [self.view addSubview:slider]; slider.value = [UIScreen mainScreen].brightness; //начальное значение
Modify the
- (void)changeBrightness:(UISlider*)sender { [UIScreen mainScreen].brightness = sender.value; }
It only works on the device, not the simulator.