Post

Replies

Boosts

Views

Activity

How do you calculate the keyboard height on an iPhone X?
The top of the keyboard needs to be about 2 inches from the bottom of the *device* as it is held.Prior to the iPhone X, this is easy because all devices used the exact same bezel insets, so it's 216 pts from the bottom of the screen.How do we calculate this height on an iPhone X? Safe area insets alone not sufficient for calculating 2 inches from the bottom of the device. Here's how I'm doing it now:@implementation UIScreen(MyExtensions) - (UIEdgeInsets)standardBezelInsets { CGSize iPhoneXSize = CGSizeMake(375, 812); if (CGSizeEqualToSize(self.bounds.size, iPhoneXSize)) { return (UIEdgeInsets) { .top = 43, .bottom = 74 }; // 290 - 216 } return UIEdgeInsetsZero; } @end @implementation MyKeyboardView - (CGFloat)preferredHeight { return [[UIScreen mainScreen] standardBezelInsets].bottom + 216; } ... @endThere are a few problems with that.Is there a better way?
3
0
7.4k
Oct ’17