문제

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.

도움이 되었습니까?

해결책

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.

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top