Search code examples
iosuser-interfacestylesswitching

Is it possible to just detect (not change) current brightness level on iOS screen?


Is it possible to just detect (not change) current brightness level on iOS screen? For example, I am trying to set a certain brightness value at which the UI/styles may change based on the current context. Sort of like responsive stylesheet switching, but instead of using dimensions I want to change per brightness.

If you have heard of this on any mobile operating system, please let me know that as well. Thank you for your time!

I am asking this to propose a project to an engineer, thus my limited knowledge of the code. Just looking for a yes or not possibility. I need to understand the feasibility before I propose it and have not found information on this elsewhere.


Solution

  • Just to clarify since you seem confused between getters and setters:

    To read either:

    float brightness = [[UIScreen mainScreen] brightness];
    

    or

    float brightness = [UIScreen mainScreen].brightness;
    

    To change:

    float brightness = XX;
    [[UIScreen mainScreen] setBrightness:brightness];
    

    or

    float brightness = XX;
    [UIScreen mainScreen].brightness = brightness;