ios 设置状态栏背景颜色

第一种方法:

    [UIApplication sharedApplication].statusBarStyle = UIStatusBarStyleBlackOpaque;

    self.navigationController.navigationBar.tintColor = [UIColor blackColor];

    if (is_ios_7_Later) {

        self.view.window.frame =  CGRectMake(0, 20, self.view.window.frame.size.width, self.view.window.frame.size.height - 20);

        [[UIApplication sharedApplication] setStatusBarStyle:UIStatusBarStyleBlackTranslucent animated:NO];

    }

另外一种方法(这方法比較简单):

    UIView *statusBarView=[[UIView alloc] initWithFrame:CGRectMake(0, 0, 320, 20)];

    statusBarView.backgroundColor=[UIColor blackColor];

    [self.view addSubview:statusBarView];

    [[UIApplication sharedApplication] setStatusBarStyle:UIStatusBarStyleLightContent animated:NO];

posted on 2017-08-20 09:12  ljbguanli  阅读(858)  评论(0编辑  收藏  举报