关于ios7 状态栏自动适应的问题

目前开发了一个项目 发现状态栏 在ios6 和ios7上 不太一样  查了下资料 发现在ios7  状态栏不在是属于系统了
而是属于 当前view的一部分 


自己搞了个解决的适应办法 

//判断当前版本是否为ios7

NSUInteger DeviceSystemMajorVersion();

NSUInteger DeviceSystemMajorVersion()

{

    static NSUInteger _deviceSystemMajorVersion = -1;

    static dispatch_once_t onceToken;

    dispatch_once(&onceToken, ^{

        _deviceSystemMajorVersion = [[[[[UIDevice currentDevice] systemVersion] componentsSeparatedByString:@"."] objectAtIndex:0] intValue];

    });

    return _deviceSystemMajorVersion;

}

#define IS_IOS_7 (DeviceSystemMajorVersion() >= 7)


- (void)loadView{

    self.view = [[UIView alloc]initWithFrame:[UIScreen mainScreen].bounds ];

    self.view.autoresizingMask = UIViewAutoresizingFlexibleWidth | UIViewAutoresizingFlexibleHeight;

    //背景颜色

    self.view.backgroundColor = [UIColor colorWithRed:238.0f/255 green:238.0f/255 blue:238.0f/255 alpha:1];


    //当前contentView

    self.contentView = [[UIView alloc]initWithFrame:[UIScreen mainScreen].bounds ];

    self.contentView.autoresizingMask = UIViewAutoresizingFlexibleWidth | UIViewAutoresizingFlexibleHeight;


    //判断当前是什么版本

    if (IS_IOS_7) {

        self.contentView.frame = CGRectMake(self.contentView.frame.origin.x, 20, self.contentView.frame.size.width, self.contentView.frame.size.height - 20);

    }else{

        self.contentView.frame = [UIScreen mainScreen].bounds;

    }

    

    [self.view addSubview:self.contentView];

}


ios7上  状态栏 还有个问题  就是 状态栏会根据 你当前的self.view 来自动适应颜色 

但是 如果你给导航栏 设置了图片  那么状态栏就不会根据变化了 



  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值