开发者

How to adjust the brightness of the device from our app in iPad

开发者 https://www.devze.com 2023-03-08 14:29 出处:网络
I am de开发者_Python百科veloping a eBook reader app for iPad and i want to add a feature where in the user can adjust the brightness of the device from the app. Is there anyway in which i can implemen

I am de开发者_Python百科veloping a eBook reader app for iPad and i want to add a feature where in the user can adjust the brightness of the device from the app. Is there anyway in which i can implement this in my app..???


I found rather a simple solution for it. I am adding a UIVIew of clear color to my book reader view and i am increasing the alpha component of this view upon the slider value changed event. By doing this , my view gets darkened and we get a feeling that the brightness of the app is reduced.. This solution may not be very appropriate, but works just fine in my case. Any better solutions are always appreciated.Thank you...


well, its not the exact solution, but it will serve the purpose...

 -(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];       
}
0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号