如何在 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
类有一个新的 属性名为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
属性采用从 0
到 1
的浮点数.所以:
The brightness
property takes a float from 0
to 1
. So:
- 将
wantsSoftwareDimming
设置为NO
(默认值),0
的brightness
表示最暗的硬件支持",而1
的brightness
表示硬件支持的最亮". - 将
wantsSoftwareDimming
设置为YES
,0
的brightness
表示最暗的硬件支持 PLUS 变暗通过叠加调光视图",而1
的brightness
仍然意味着硬件支持的最亮".
- 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屋!