如何在 iOS 5 应用程序中更改亮度? [英] How to change brightness in iOS 5 app?

查看:24
本文介绍了如何在 iOS 5 应用程序中更改亮度?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如何编程在应用内更改亮度的功能?我知道这是可能的,因为我已经看到至少三个可以做到这一点的应用程序.这对我的应用程序非常有用.我知道它只能在 iOS 5 中使用 UIScreen 类,但我不知道如何对其进行编程.请帮帮我!

How would I program the ability to change brightness in-app? I know that its possible as I have seen at least three apps that can do it. This would be very useful for my app. I know that it's only possible in iOS 5 with the UIScreen Class, but I have no idea how to program it. Please help me!

推荐答案

UIScreen 类有一个新的 属性名为brightness.

The UIScreen class has a new property called brightness.

此外,还有另一个名为 wantsSoftwareDimming 的属性(当设置为 YES 时)允许您低于硬件支持的最低亮度,因为特殊的调光view" 覆盖在屏幕上,以进一步使事物变暗.

In addition, there's another property called wantsSoftwareDimming that (when set to YES) allows you to go below the lowest brightness supported by the hardware, because a special "dimming view" is overlaid over the screen to darken things even further.

brightness 属性采用从 01 的浮点数.所以:

The brightness property takes a float from 0 to 1. So:

  • wantsSoftwareDimming 设置为 NO(默认值),0brightness 表示最暗的硬件支持",而 1brightness 表示硬件支持的最亮".
  • wantsSoftwareDimming 设置为 YES0brightness 表示最暗的硬件支持 PLUS 变暗通过叠加调光视图",而 1brightness 仍然意味着硬件支持的最亮".
  • with wantsSoftwareDimming set to NO (the default), a brightness of 0 means "the darkest the hardware supports" and a brightness of 1 means "the brightest the hardware supports".
  • with wantsSoftwareDimming set to YES, a brightness of 0 means "the darkest the hardware supports PLUS darkening by overlaying a dimming view", and a brightness of 1 still means "the brightest the hardware supports".

这篇关于如何在 iOS 5 应用程序中更改亮度?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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