I added view just like you
![enter image description here]()
with constraints
![enter image description here]()
Added this view as inputAccessoryView
myTextField.inputAccessoryView = viewAccessory
And its working fine
![enter image description here]()
Edit - ToolBar as InputAccesory
You can achieve this with toolbar (w/o any constraint headache). Check below steps.
Select a toolbar like below and add this tool bar is place of your view.
![enter image description here]()
![enter image description here]()
Now add buttons like shown in above image by dragging and dropping UIBarButtonItem
and assign images each BarButton. To make it flexible width and equally distributed just add Flexible Space Bar Button Item
.
![enter image description here]()
Now your toolbar hierarchy should be like below
![enter image description here]()
And in your code
@IBOutlet var toolBarAccessory: UIToolbar!
@IBOutlet weak var myTextField: UITextField!
override func viewDidLoad() {
super.viewDidLoad()
myTextField.delegate = self
myTextField.inputAccessoryView = toolBarAccessory
}
Output:
![enter image description here]()