如何在iOS 5应用程序中更改亮度? [英] How to change brightness in iOS 5 app?
问题描述
我如何编写在应用程序中更改亮度的功能?我知道它可能,因为我已经看到至少有三个应用程序可以做到这一点。这对我的应用程序非常有用。我知道它只能在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
类有一个新的名为<$ c $的属性c>亮度 。
The UIScreen
class has a new property called brightness
.
此外,还有另一个名为 wantSoftwareDimming
(当设置为 YES
时)允许您低于硬件支持的最低亮度,因为屏幕上会覆盖一个特殊的调光视图以使事情变暗
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.
亮度
属性从 0
到 1
。所以:
-
wantsSoftwareDimming
设置为否
(默认值),亮度
0
表示硬件支持的最黑暗和亮度
1
表示硬件支持最亮。 - with
wantsSoftwareDimming
设置为YES
,亮度
0
表示最黑暗的硬件通过覆盖调光视图支持PLUS变暗,以及亮度
1
仍然意味着最聪明的硬件支持。
- with
wantsSoftwareDimming
set toNO
(the default), abrightness
of0
means "the darkest the hardware supports" and abrightness
of1
means "the brightest the hardware supports". - with
wantsSoftwareDimming
set toYES
, abrightness
of0
means "the darkest the hardware supports PLUS darkening by overlaying a dimming view", and abrightness
of1
still means "the brightest the hardware supports".
这篇关于如何在iOS 5应用程序中更改亮度?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!