How to Change the color of status bar

后端 未结 5 1844
庸人自扰
庸人自扰 2021-01-04 04:31

How can we change the color of the status bar? I know we can change the style by

[application setStatusBarStyle:UIStatusBarStyleBlackOpaque];


        
相关标签:
5条回答
  • 2021-01-04 04:52
    [UIApplication sharedApplication].statusBarStyle = UIStatusBarStyleBlackOpaque;
    
    0 讨论(0)
  • 2021-01-04 04:55

    Just for information, for those who don't want to change view frames, setting window background will also work.

    I wrote this in AppDelegate.

    self.window.backgroundColor = [UIColor colorWithRed:0.78f green:0.13f blue:0.11f alpha:1];
    [[UIApplication sharedApplication] setStatusBarStyle:UIStatusBarStyleBlackTranslucent];
    
    0 讨论(0)
  • 2021-01-04 04:57

    Actually, you can, but it's a hack (and apple def. has another, better way of doing it that we don't have access to):
    Set the status bar to black translucent and have a (sub)view with your wanted color as backgroundcolor directly behind it. That way you can get the effect of a different color, even with a gradient.
    the frame for that would be CGRectMake(0,0,320,20)

    0 讨论(0)
  • 2021-01-04 05:02

    You can't select arbitrary colors for the iOS status bar. You can only choose between white, black opaque and translucent black.

    0 讨论(0)
  • 2021-01-04 05:03
     self.window.backgroundColor=[UIColor redColor];
    
    0 讨论(0)
提交回复
热议问题