Change Backlight Brightness on iPhone Programmatically

后端 未结 5 1101
無奈伤痛
無奈伤痛 2020-12-01 23:15

Does the SDK provide any way to change the brightness of the backlight, or turn it off temporarily?

5条回答
  •  一整个雨季
    2020-12-01 23:46

    In my SDK (5.0.1) it seems that "GraphicsServices.h" is no longer there, but you can declare it yourself like this:

    void GSEventSetBacklightLevel(float level);
    

    Note that the linker will complain, unless you include the framework GraphicsServices.framework in your project.

    About your question about turning the backlight off, I found out that you can do it by passing a very large negative number to GSEventSetBacklightLevel, like this:

    GSEventSetBacklightLevel(-INFINITY);
    

    In my tests this will completely black out the screen.

    Remember that this might still cause burn-in in the LCD pixels if you display static graphics, even when the backlight is off. And that this call will cause rejection if submitteed to app store.

提交回复
热议问题