How to detect in Swift if the current device (iPhone) has a physical home button or hasn't, like: iPhone X, iPhone Xs, iPhone Xs Max, iPhone Xr ?
The iPhone SE 2022 is the only current iPhone model with a home button.
How To Show The Home Button On Your iPhone's Screen. Go to Settings -> Accessibility -> Touch -> AssistiveTouch and tap the switch next to AssistiveTouch to turn it on. To use the Home button, tap the AssistiveTouch button on the screen, then tap Home.
Apple's introduced the latest of it's line up of iPhones with no Home button. The iPhone 12 series joins the iPhone 11 series, and the iPhone XR, XS and X with a full screen front and Face ID.
For iOS 13 and higher:
var isBottom: Bool {
if #available(iOS 13.0, *), UIApplication.shared.windows[0].safeAreaInsets.bottom > 0 {
return true
}
return false
}
Check the safe area:
if @available(iOS 11.0, *),
UIApplication.sharedApplication.keyWindow?.safeAreaInsets.bottom > 0 {
return true
}
return false
Swift 4.2 version:-
var isBottom: Bool {
if #available(iOS 11.0, *), let keyWindow = UIApplication.shared.keyWindow, keyWindow.safeAreaInsets.bottom > 0 {
return true
}
return false
}
You can also check the device type (check out this post), but checking the safe area is probably the easiest way.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With