Open1

[SwiftUI] キーボードの高さを取得する

Yusuke AriyoshiYusuke Ariyoshi
.onReceive(NotificationCenter.default.publisher(for: UIResponder.keyboardWillShowNotification)) { notification in
  if let keyboardFrame = notification.userInfo?[UIResponder.keyboardFrameEndUserInfoKey] as? NSValue {
    let keyboardHeight = keyboardFrame.cgRectValue.height
    print(keyboardHeight)
  }
}