iOS 改变状态栏颜色

2022-03-28  本文已影响0人  冬日的太阳_c107

- (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"];

       };

   }

}

上一篇下一篇

猜你喜欢

热点阅读