UItextview使用Keyboard Swift调整所有设备的高度

时间:2018-02-08 20:23:48

标签: swift swift3 uitextview uitoolbar uikeyboard

我在键盘顶部有一个UIToolBar,这是我的代码

extension UIViewController: UITextFieldDelegate {
    func addToolBar(textField: UITextField) {
        let toolBar = UIToolbar()
        toolBar.barStyle = .default
        toolBar.isTranslucent = true
        toolBar.tintColor = UIColor(red: 76 / 255, green: 217 / 255, blue: 100 / 255, alpha: 1)
        let doneButton = UIBarButtonItem(title: "Done", style: .done, target: self, action: #selector(donePressed))
        let cancelButton = UIBarButtonItem(title: "Cancel", style: .plain, target: self, action: #selector(cancelPressed))
        let spaceButton = UIBarButtonItem(barButtonSystemItem: .flexibleSpace, target: nil, action: nil)
        toolBar.setItems([cancelButton, spaceButton, doneButton], animated: false)


        toolBar.isUserInteractionEnabled = true
        toolBar.sizeToFit()

        textField.delegate = self
        textField.inputAccessoryView = toolBar
    }

我在Storyboard中有一个UITextview,我想用 Y = 0 调整UITextView 高度的大小,以便它适合所有设备的工具栏。我知道uitoolbar它是44 高度。有谁知道我该怎么做?

0 个答案:

没有答案