在iOS13中,苹果使用UIStatusBarManager来获取StatusBar的状态和属性,之前的StatusBar高度获取被弃用,最新的获取方式如下:
float statusBarHeight = 0;if (@available(iOS 13.0, *)) { UIStatusBarManager *statusBarManager = [UIApplication sharedApplication].windows.firstObject.windowScene.statusBarManager; statusBarHeight = statusBarManager.statusBarFrame.size.height;}else { statusBarHeight = [UIApplication sharedApplication].statusBarFrame.size.height;}