0
如何在點擊按鈕時更改屏幕亮度?我正在使用此代碼如何降低屏幕的亮度?
[[UIScreen mainScreen] setBrightness:0.3f];
但它不再工作。我已將此代碼放入按鈕單擊操作中。我需要做什麼特殊的事情來處理這個或任何我需要包含的框架?
如何在點擊按鈕時更改屏幕亮度?我正在使用此代碼如何降低屏幕的亮度?
[[UIScreen mainScreen] setBrightness:0.3f];
但它不再工作。我已將此代碼放入按鈕單擊操作中。我需要做什麼特殊的事情來處理這個或任何我需要包含的框架?
我用這個:
//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];
}
可能它會幫助你,謝謝。
Thanx dev。但我認爲你的方法沒有任何區別 - (void)adjustImageBrightnessWithValue :(CGFloat)的值 {[UIScreen mainScreen] setBrightness:value]; }和我提到的那一個。 [[UIScreen mainScreen] setBrightness:0.3f];是這樣嗎? – pankaj
請檢查一下,因爲我給:http://www.datafilehost.com/d/ea81e71b –