iOS 5中获取屏幕亮度值

发布于 2024-12-27 21:29:31 字数 87 浏览 2 评论 0原文

我已经开始在 UIScreen 中使用新的 iOS 5 亮度设置器。是否有一个 getter 属性可以用来了解启动时显示亮度的设置?

非常感谢。

I've started to use the new iOS 5 brightness setter in UIScreen. Is there a getter property I can use to know what the display brightness is set to on launch?

Thanks very much.

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

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

发布评论

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

评论(1

奢欲 2025-01-03 21:29:31

相同的财产。这些是我在更改之前用来存储当前亮度的方法,然后将亮度重置为之前的值:

- (void)dimScreen {
    previousBrightness = [UIScreen mainScreen].brightness;
    [UIScreen mainScreen].brightness = 0;
}

- (void)restoreScreen {
    [UIScreen mainScreen].brightness = previousBrightness;
}

更新: 值得注意的是,UIScreen 报告的亮度非常有用仅是用户在“设置”中设置的亮度,不报告自动亮度调节值。如果启用自动亮度,我知道无法获得调整后的值。

举个例子,如果用户在“设置”中将亮度滑块设置为 100%,但当前处于非常黑暗的房间中,则 UIScreen 将报告亮度为 1.0,但真实值可能更接近0.5。

The same property. These are the methods I use to store the current brightness before changing it, then reset brightness to the previous value later:

- (void)dimScreen {
    previousBrightness = [UIScreen mainScreen].brightness;
    [UIScreen mainScreen].brightness = 0;
}

- (void)restoreScreen {
    [UIScreen mainScreen].brightness = previousBrightness;
}

Update: It's useful to note that the brightness reported by UIScreen is only the brightness the user has set in Settings, and does not report the auto brightness adjusted value. If auto brightness is enabled, I am aware of no way to get the adjusted value.

As an example, if the user has the brightness slider at 100% in Settings but they are currently in a very dark room, then UIScreen will report a brightness of 1.0, but the true value might be closer to 0.5.

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