如何获得通过的iOS给一个自定义键盘的视线的高度?
我目前手动设置键盘接口为iPhone 8加:
var keyboardHeight: CGFloat {
return UIScreen.main.bounds.height > UIScreen.main.bounds.width ? 226 : 162
}
如何获得键盘的所有大小类编程的高度?
尝试这个
override func viewDidLoad() {
super.viewDidLoad()
let desiredHeight: CGFloat = 500
let heightConstraint = NSLayoutConstraint(item: view, attribute: .height, relatedBy: .equal, toItem: nil, attribute: .notAnAttribute, multiplier: 1.0, constant: desiredHeight)
view.addConstraint(heightConstraint)
self.nextKeyboardButton.addTarget(self, action: #selector(handleInputModeList(from:with:)), for: .allTouchEvents)
}
该方法是通常的一个:listen to keyboard notifications and respond to them。
随着通知的发送endFrame
字典的userInfo
键包含键盘的正确尺寸。我考虑也最终accessoryInputView
。