iOS 开启热点后对状态栏的影响

一、开启热点后状态栏的改变

 iPhone作为个人热点,且有连接时,状态栏会纵向下压20像素,状态栏的高度变成40像素;当所有连接断开后,恢复到20像素。

[UIApplication sharedApplication].statusBarFrame.size.height (状态栏的高度)

二、系统版本对状态栏的影响

当有热点栏时,UIViewController.view.bounds.height自动去掉了热点栏的高度,iOS<7.0不包含标准系统状态栏,iOS≥7.0包含标准系统状态栏。
由于iOS7把整个屏幕高度(包括状态栏,不包括热点栏)都作为了视图控制器的有效高度,因此从iOS6升级到iOS7时,会出现视图整体上移了一个状态栏的高度(20pt),并和上层的状态栏交叠在一起。

[[[UIDevice currentDevice] systemVersion] doubleValue] (系统版本)

三、代码

// 在相应的ViewController 写适配方法
- (void)adapterstatusBarHeight{
// 之所以加这段代码,是因为当设置个人wifi热点等情况下,状态栏高度会由20像素变成40像素
// 导致底部的tab被往下挤掉一部分,所以这种情况下,tab的Y坐标就要向上移动20像素
CGRect statusBarRect = [[UIApplication sharedApplication] statusBarFrame];
int shouldBeSubtractionHeight = 0;
if (statusBarRect.size.height == 40) {
shouldBeSubtractionHeight = 20;
}
if ([[UIDevice currentDevice].systemVersion floatValue]>=7.0[[UIDevice currentDevice].systemVersion floatValue]<6.0) {
tabBar.frame = CGRectMake(0, __MainScreen_Height-49 - shouldBeSubtractionHeight , 320, 49);
}else{
tabBar.frame =CGRectMake(0, __MainScreen_Height-69 - shouldBeSubtractionHeight , 320, 49);
}
}

在AppDelegate的这个函数函数去调用
- (void)applicationDidBecomeActive:(UIApplication *)application
{
// Restart any tasks that were paused (or not yet started) while the application was inactive. If the application was previously in the background, optionally refresh the user interface.
[[UIApplication sharedApplication] cancelAllLocalNotifications];
application.applicationIconBadgeNumber = 0;
[[mainViewController sharedmain] adapterstatusBarHeight];
}

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值