如何降低屏幕亮度?

时间:2013-10-03 12:53:53

标签: objective-c ipad ios6

如何在点击按钮时更改屏幕亮度?我正在使用此代码

[[UIScreen mainScreen] setBrightness:0.3f];

但它不再起作用了。我已将此代码放在按钮单击操作中。对于我需要包含的这个或任何框架,我需要做些什么特别的事情吗?

1 个答案:

答案 0 :(得分:0)

在我的应用程序中我使用了这个:

//take slider in .h file

  self.slider = [[UISlider alloc] initWithFrame:CGRectMake(give your frame)];

self.slider.minimumValue = 0;//here you have to set min value of slider as per you want
self.slider.maximumValue = 1;//here you have to set max value of slider as per you want
 self.slider.continuous = YES;

int myVal = self.slider.value;
NSString *timeValue = [[NSString alloc] initWithFormat:@"%1d", myVal];

self.timeLabel.text = timeValue;

 // Attach an action to sliding
  [self.slider addTarget:self action:@selector(sliderChanged:) forControlEvents:UIControlEventValueChanged];

 - (void)sliderChanged:(UISlider *)sender
{
  [self adjustImageBrightnessWithValue:sender.value];
}

- (void)adjustImageBrightnessWithValue:(CGFloat)value
{
  [[UIScreen mainScreen] setBrightness:value];
}

可能对你有所帮助,谢谢。