UIScreen 亮度属性 [英] UIScreen Brightness Property

查看:24
本文介绍了UIScreen 亮度属性的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

目前我正在尝试创建一个应用程序来调整设备的亮度.在 iOS5 中,mainScreen 有一个新的亮度属性,允许您设置屏幕亮度.我正在使用以下代码:

At the moment I'm trying to create an application to adjust the device's brightness. In iOS5, there is the new brightness property for mainScreen that allows you to set the screen brightness. I'm using the following code:

[[UIScreen mainScreen] setBrightness:1.0];

然而,这似乎只在设备锁定之前有效,并且不会保存在设置中.是不是我做错了什么?

However this seems to only work until the device is locked, and doesn't get saved in settings. Is there something I'm doing wrong?

推荐答案

您需要在 NSUserDefaults 中保存要自己设置的值并调用 setBrightness:在您的应用程序委托的 applicationDidBecomeActive: 恢复亮度的方法.

You will need to save the value you want to set yourself in your NSUserDefaults and call setBrightness: in your application delegate's applicationDidBecomeActive: method to restore the brightness.

这篇关于UIScreen 亮度属性的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆