如何实现键盘上方的按钮? (例如:“注释”应用,或
like this

最佳答案

MKaro的解决方案有效!我将附上Swift 3版本,以实现更快的复制粘贴。

Swift 3:

let keyboardToolbar = UIToolbar()
keyboardToolbar.sizeToFit()
keyboardToolbar.isTranslucent = false
keyboardToolbar.barTintColor = UIColor.white

let addButton = UIBarButtonItem(
    barButtonSystemItem: .done,
    target: self,
    action: #selector(someFunction)
)
addButton.tintColor = UIColor.black
keyboardToolbar.items = [addButton]
textView.inputAccessoryView = keyboardToolbar

07-26 01:03