iOS 改变状态栏颜色

- (void)viewDidAppear:(BOOL)animated {

    [superviewDidAppear:animated];

    UIView*statusBarView;

   if(@available(iOS13.0, *)) {

       statusBarView = [[UIView alloc] initWithFrame:[UIApplication sharedApplication].keyWindow.windowScene.statusBarManager.statusBarFrame];

       statusBarView.backgroundColor= [UIColorcolorWithHexString:@"#5a9eff"];

       [[UIApplication sharedApplication].keyWindow addSubview:statusBarView];

   }else{

       statusBarView= [[[UIApplication sharedApplication] valueForKey:@"statusBarWindow"] valueForKey:@"statusBar"];

       if([statusBarViewrespondsToSelector:@selector(setBackgroundColor:)]) {

           statusBarView.backgroundColor= [UIColorcolorWithHexString:@"#5a9eff"];

       };

   }

}

你可能感兴趣的:(iOS 改变状态栏颜色)