2

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

非常感谢。

4

1 回答 1

11

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.

于 2012-01-23T05:44:15.740 回答