applicationWillResignActive and setBrightness not working?

后端 未结 6 1196
误落风尘
误落风尘 2021-01-03 20:17

I use [[UIScreen mainScreen]setBrightness: ] (in sdk 5.0) to change the system background light in my app.

The following steps work with my app:

  1. Act

6条回答
  •  耶瑟儿~
    2021-01-03 21:03

    When you tap the home button your application doesn't resign active but rather goes into "Background Mode" and has its own delegate method which you need to define:

    - (void)applicationDidEnterBackground:(UIApplication *)application
    

    Something like this (in addition to the applicationDidBecomeActive: delegate method) should get the intended behavior:

    - (void)applicationDidEnterBackground:(UIApplication *)application
    {        
        sysBright = [[NSUserDefaults standardUserDefaults] floatForKey:@"sysBright"];
        [[UIScreen mainScreen] setBrightness:sysBright]; 
    }
    

提交回复
热议问题