iOS自定义状态栏

//创建一个高20的假状态栏背景

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

    

    //设置颜色

    UILabel * statusLabel = [[UILabel alloc] initWithFrame:statusBarView.bounds];

            statusLabel.text = @"正在加载中。。。";

            statusLabel.textColor = [UIColor whiteColor];

            statusLabel.textAlignment = NSTextAlignmentCenter;

            statusLabel.backgroundColor = [UIColor blackColor];

    [statusBarView addSubview:statusLabel];

    

    statusBarView.backgroundColor=[UIColor blackColor];

    

    //这里我的思路是:之前不理想的状态是状态栏颜色也变成了导航栏的颜色,但根据这种情况,反而帮助我判断出此时的状态栏也是导航栏的一部分,而状态栏文字浮于上方,因此理论上直接在导航栏上添加一个subview就是他们中间的那一层了。

    //推得这样的代码:

    [self.navigationController.navigationBar addSubview:statusBarView];


  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值