Just enclose your textbox inside a view and then override inputAccessoryView returning the view. Important: Your view should be created programmatically. Do not use @IBOutlets.
override var inputAccessoryView: UIView? {
get {
return newlyProgramaticallyCreatedView
}}