applicationWillResignActive and setBrightness not working?

后端 未结 6 1199
误落风尘
误落风尘 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:20

    Since the current methods don't work in the app delegate methods, you can use a UIView as described by Adam.

    Make a UIView lvar in the delegate h file:

    UIView *view_;
    

    Then in the implementation:

    // create view in app delegate didFinishLaunchingWithOptions method and add it to the window
    view_ = [[UIView alloc] initWithFrame:self.window.frame]; // delegate lvar
    [view_ setBackgroundColor:[UIColor blackColor]];
    [view_ setAlpha:0.5];
    [self.window addSubview:view_];
    [self.window makeKeyAndVisible];
    return YES;
    

    Make the view the size of your screen or view controller as needed. and make sure it's on top of all other subviews.

    Keep in mind this will have a significant affect on the graphics performance of the app, but unless you are doing something crazy with the UI, it should be okay.

提交回复
热议问题