2011-05-27 41 views
2

我正在開發一款適用於iPad的電子書閱讀器應用程序,並且我想添加一項功能,用戶可以在該應用程序中調整設備的亮度。無論如何,我可以在我的應用程序中實現這一點..?如何在iPad中調整設備的亮度

+1

的可能重複[更改背光亮度上iPhone編程] (http://stackoverflow.com/questions/366889/change-backlight-brightness-on-iphone-programmatically) – 2011-05-27 09:10:37

+0

對不起,我發佈問題之前檢查了SOF,但我什麼都找不到。所以,我發佈了這個問題。無論如何,我已經找到了我的問題的答案,我已經在答覆欄中發佈了它。 – 2011-05-27 10:36:18

回答

1

我發現,而它一個簡單的解決方案。我是添加一個清晰的顏色的UIVIew到我的書閱讀器視圖,我在滑塊值更改事件增加此視圖的alpha組件。通過這樣做,我的視角變暗了,我們感覺應用程序的亮度降低了。這種解決方案可能不太合適,但對我來說工作得很好。沒有更好的辦法總是appreciated.Thank你......

+0

你可以請張貼一些代碼嗎?我沒有得到確切的結果,我需要在我的應用程序中實現同樣的功能。 此致! – Akshay 2011-06-17 04:36:03

+0

@Akshay Thakur:我發佈了代碼..試試看,讓我知道輸出.... – 2011-06-17 05:47:13

0

請點擊此link

希望它的作品...

0

好,它不是確切的解決方案,但它會達到目的......

-(IBAction)sliderValueChangedForBrightness:(UISlider*)sliderObj{ 

    brightnessView.backgroundColor=[[UIColor grayColor] colorWithAlphaComponent:1-sliderObj.value]; 
} 

-(IBAction)adjustBrightness:(UIButton *)sender{ 

    if(isbrightnessViewShowing==NO){ 
     isbrightnessViewShowing=YES; 
     [self.view addSubview:brightnessSliderView]; 
     brightnessSliderView.frame=CGRectMake(sender.frame.origin.x-70,brandingView.frame.size.height, brightnessSliderView.frame.size.width, brightnessSliderView.frame.size.height); 
    } 
    else { 
     isbrightnessViewShowing=NO; 
     [brightnessSliderView removeFromSuperview]; 
    } 

    if (brightnessView==nil) { 
     brightnessView = [[UIView alloc] initWithFrame:CGRectMake(0, 0, scrollView.frame.size.width, scrollView.frame.size.height)]; 
     brightnessView.backgroundColor = [UIColor clearColor]; 
    } 

    [webView addSubview:brightnessView]; 
    [webView bringSubviewToFront:brightnessView];  
}