如何使用发送按钮添加一个块,使其随键盘移动。而且那将是textview表现相同。
预览
最佳答案
将此代码添加到您的控制器中
func createInputAccessoryView () -> UIToolbar {
let toolbarAccessoryView = UIToolbar(frame: CGRect(x: 0, y: 0, width: self.view.bounds.size.width, height: 44))
toolbarAccessoryView.barStyle = .default
toolbarAccessoryView.tintColor = UIColor.blue
let flexSpace = UIBarButtonItem(barButtonSystemItem:.flexibleSpace, target:nil, action:nil)
let doneButton = UIBarButtonItem(barButtonSystemItem:.done, target:self, action:Selector(("doneTouched")))
toolbarAccessoryView.setItems([flexSpace, doneButton], animated: false)
return toolbarAccessoryView
}
@objc func doneTouched() {
/* Your action goes here */
}
现在将其添加到您的viewDidLoad或任何地方
yourTextView.inputAccessoryView = createInputAccessoryView ()
关于ios - 标签贴在键盘上,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/48906542/