Get safe area inset top and bottom heights
问题 On the new iPhone X, what would be the most proper way to get both top and bottom height for the unsafe areas? 回答1: Try this : In Objective C if (@available(iOS 11.0, *)) { UIWindow *window = UIApplication.sharedApplication.keyWindow; CGFloat topPadding = window.safeAreaInsets.top; CGFloat bottomPadding = window.safeAreaInsets.bottom; } In Swift if #available(iOS 11.0, *) { let window = UIApplication.shared.keyWindow let topPadding = window?.safeAreaInsets.top let bottomPadding = window?