title: iPhoneX and iPhone 8 keyboard height are different
body: <p>I use below code to get keyboard height. Then use this height to calculate the frame of an <code>UIView</code> to make sure this <code>UIView</code> just on the top of the keyboard. </p>
  
  <p>But in iPhoneX simulator the output is <code>333</code> and the iPhone 8 simulator is <code>258</code>. </p>
  
  <p><strong>ISSUE</strong>: If use <code>rect.height</code> as the keyboard height for iPhone 8 simulator then the layout is correct. For iPhone X there's a gap between the <code>UIView</code> and keyboard. Which means <code>333</code> is higher than the real keyboard height in iPhone X.</p>
  
  <p>What's the reason of the height are different? And how to get the correct keyboard height?</p>
  
  <pre><code>NotificationCenter.default.addObserver(self, selector: #selector(keyboardWillShow), name: .UIKeyboardWillShow, object: nil)
  
  
  @objc func keyboardWillShow(_ notification: NSNotification) {
          if let rect = (notification.userInfo?[UIKeyboardFrameEndUserInfoKey] as? NSValue)?.cgRectValue {
             print(rect.height)
          } 
      }
  </code></pre>
  
  <p>Like this image, the green border should be the extra part. Actually, I need the red part just on the top of keyboard without the green rect gap.
  <a href="https://i.stack.imgur.com/ZQNDr.jpg" rel="noreferrer"><img src="https://i.stack.imgur.com/ZQNDr.jpg" alt="enter image description here"></a></p>
  
  <p><strong>EDIT</strong></p>
  
  <p>OK, with @Craig's help I found this method only called by iPhone X. So I update frame here. Just paste the code here.</p>
  
  <p>The safe area bottom height is 22.0 seems not correct.</p>
  
  <pre><code>override func viewSafeAreaInsetsDidChange() {
      if #available(iOS 11.0, *) {
          super.viewSafeAreaInsetsDidChange()
          view.safeAreaInsets.bottom // This value is the bottom safe area place value.
      }
  }
  </code></pre>
  
  <p><strong>EDIT2</strong>
  Normally <code>view.safeAreaInsets.bottom</code> should be 34.0, but if you are using container view this value can be different like mine is 22.0.</p>