Here you can find swift examples.
Add this into your viewDidLoad()
- best way.
let bar = UIToolbar()
let uiBarItem1 = UIBarButtonItem(title: "Encode", style: .plain, target: self, action: #selector(buttonTapped))
let uiBarItem2 = UIBarButtonItem(title: "Encode", style: .plain, target: self, action: #selector(buttonTapped))
bar.items = [uiBarItem1, uiBarItem2]
bar.sizeToFit()
yourCustomTextView.inputAccessoryView = bar
Create buttonTapped()
function.
@objc func encodeTapped(_ sender: UIBarButtonItem) {
print("Hello World!")
}
Add this into your ViewController
class.
override func touchesBegan(_ touches: Set<UITouch>, with event: UIEvent?) {
view.endEditing(true)
}