简体   繁体   中英

Dim iPhone back light on upside down

I have seen on an iOS application 'Sleep Cycle Alarm Clock' that when the iPhone is facing screen down (towards the floor) they have managed to dim the back light of the screen. I have been searching all over the internet and can't find the API that provides this functionality.

I am guessing that they achieve this by measuring acceleration on the device from gravity and dimming the back light accordingly, which I have no problem with. I just don't know how they have dimmed the back light (including the status bar!). It's not a semi-transparent black UIView overlayed on the superview, the light definitely switches off.

The detection isn't the issue, it's the dimming that I don't know how to do.

Can anyone point me to the correct method/API documentation? I'm using the iOS 6 SDK.

Thanks

EDIT:

Sorry guys, appears that I was wrong. Further investigation leads me to believe they haven't dimmed the backlight. The instructions stay over the superview temporarily. I think they actually overlay a black image and remove the status bar. My apologies! To get around the orientation lock for orientation detection I think they use the accelerometer.

Detecting if the device is face down can be done by using UIDevice orientation . This will return UIDeviceOrientationFaceDown when the screen is facing toward the floor.

Have a look at the UIScreen class for a couple of methods related to brightness.

Try this:

[[UIScreen mainScreen] setBrightness:0.5]; //Any value you think works

for more information about UIScreen and what you can do with it look at the documentation:

UIScreen Apple Documentation

EDIT: Just read the comments on the other answer, what kind of problems does this method cause?

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM