[IOS]状态栏相关设置

// 在相应的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];
}

猜你喜欢

转载自jameskaron.iteye.com/blog/2380209