IOS13以后获取状态栏高度 statusHeight

let statusHeight:CGFloat = {
   if #available(iOS 13.0, *) {
       let scene = UIApplication.shared.connectedScenes.first as? UIWindowScene
       let frame = scene?.statusBarManager?.statusBarFrame
       return frame?.height ?? 0
    } else {
       return UIApplication.shared.statusBarFrame.size.height
    }
}()

你可能感兴趣的:(IOS13以后获取状态栏高度 statusHeight)