Use a static variable
If you just want to do simple processing depending on different iPhone models, recommend the following static variable:
static var isFullScreen: Bool {
if #available(iOS 11, *) {
guard let w = UIApplication.shared.delegate?.window, let unwrapedWindow = w else {
return false
}
if unwrapedWindow.safeAreaInsets.left > 0 || unwrapedWindow.safeAreaInsets.bottom > 0 {
//print(unwrapedWindow.safeAreaInsets)
return true
}
}
return false
}
Install ScreenType by Cocoapods
ScreenType is a library to easily distinguish between iPhone models in Objective-C and Swift. And you could install it by Cocoapods.
Go to GitHub – allgamesallfree/ScreenType: Easily distinguish between iph models in Objective-C and Swift or Easily distinguish between iph models – maxste.in in order to find further explanations.
分类:iOS