Changing status bar style ios 7?

2019-04-02 05:29发布

I am trying to change the status bar style of one of my viewcontrollers. I have put this

  1. set the view based status bar to YES in the plist

2.

 -(UIStatusBarStyle)preferredStatusBarStyle{
    return UIStatusBarStyleLightContent;
}
  1. Added this also

[self setNeedsStatusBarAppearanceUpdate]

It works i.e I can see the font color white but just after some time it changes back to its previous type..

标签: ios statusbar
4条回答
Fickle 薄情
2楼-- · 2019-04-02 05:50

This is the only thing I could get working for iOS7

- (UIStatusBarStyle)preferredStatusBarStyle
{
    return UIStatusBarStyleLightContent;
}
查看更多
The star\"
3楼-- · 2019-04-02 06:07

You can check this code, a little trick – but useful sometimes.

查看更多
看我几分像从前
4楼-- · 2019-04-02 06:12

write following code

-(void)viewWillAppear:(BOOL)Animated{
    [[UIApplication sharedApplication] setStatusBarStyle:UIStatusBarStyleLightContent];
}
查看更多
淡お忘
5楼-- · 2019-04-02 06:15

If you are experiencing status bar changing color itself during runtime

try setting set the UIViewControllerBasedStatusBarAppearance to NO in the plist.

And inside your viewController.. set the appearance call inside

-(void)viewDidLayoutSubviews
{
    if ([self respondsToSelector:@selector(setNeedsStatusBarAppearanceUpdate)]) {
        [self setNeedsStatusBarAppearanceUpdate];
    }
}
查看更多
登录 后发表回答