在 viewDidLoad 中添加以下行:
[[UIApplication sharedApplication] setStatusBarHidden:YES withAnimation:UIStatusBarAnimationFade];
并添加新方法
- (BOOL)prefersStatusBarHidden {
return YES;
}
也改变 info.plist 文件
View controller-based status bar appearance" = NO
并为 iPhone 6 和 6 Plus 添加条件。以下是 iPhone 6 和 6 Plus 的方法:
/*=====================================================================================================================
Checks if the device has 4.7 inch screen such as iPhone6 generation
=====================================================================================================================*/
+(BOOL) ISiPhone6
{
BOOL isIpad = ([[UIDevice currentDevice] userInterfaceIdiom] == UIUserInterfaceIdiomPad);
CGRect screenRect = [[UIScreen mainScreen] bounds];
// we need to check the maximum of width and height because some screens (the camera view while scanning) we can
// rotate to portrait or landscape and in the case the screen height and width flip
return (!isIpad && MAX(screenRect.size.height,screenRect.size.width) == 667);
}
/*=====================================================================================================================
Checks if the device has 5.5 inch screen such as iPhone6 plus
=====================================================================================================================*/
+(BOOL) ISiPhone6Plus
{
BOOL isIpad = ([[UIDevice currentDevice] userInterfaceIdiom] == UIUserInterfaceIdiomPad);
CGRect screenRect = [[UIScreen mainScreen] bounds];
// we need to check the maximum of width and height because some screens (the camera view while scanning) we can
// rotate to portrait or landscape and in the case the screen height and width flip
return (!isIpad && MAX(screenRect.size.height,screenRect.size.width) == 736);
}
它对我有用。