To support our app on iPhoneX, We may need to check whether it is running on iPhone X or not.
We can check it using device’s,
- Model
- Dimensions
To get to know whether it is iPhoneX or not, But this may fail in future If Apple comes with a device having safe area apart iPhoneX
The best way is to check whether device is having safe area or not.
-----------------------------------------------------------------------------
- (BOOL)isDeviceHavingSafeArea {
if (@available(iOS 11, *)) {
if ([UIApplication sharedApplication].keyWindow.safeAreaInsets.bottom > 0.0) {
return YES;
}
}
return NO;
}
- (UIEdgeInsets)safeAreaInsets {
if ([self isDeviceHavingSafeArea]) {
return [UIApplication sharedApplication].keyWindow.safeAreaInsets;
}
return UIEdgeInsetsZero;
}
-----------------------------------------------------------------------------
Hope this post is useful. Feel free to comment incase of any queries.
No comments:
Post a Comment