如何通过 iPad 中的应用程序调整设备的亮度

发布于 2024-11-10 04:59:13 字数 101 浏览 4 评论 0原文

我正在为 iPad 开发一个电子书阅读器应用程序,我想添加一项功能,用户可以通过应用程序调整设备的亮度。无论如何,我可以在我的应用程序中实现这个..???

I am developing 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..???

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

梦冥 2024-11-17 04:59:13

我找到了一个相当简单的解决方案。我正在添加一个清晰颜色的 UIVIew 到我的图书阅读器视图,并且在滑块值更改事件时增加该视图的 alpha 分量。通过这样做,我的视图变暗,我们感觉应用程序的亮度降低了。这个解决方案可能不是很合适,但在我的情况下效果很好。任何更好的解决方案总是值得赞赏。谢谢...

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...

海夕 2024-11-17 04:59:13

好吧,这不是确切的解决方案,但它会达到目的......

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

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];       
}
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文