5年前のことですが、私のようにあなたの質問に出くわした他の人を助けるかもしれません.
UIToolbar を inputAccessoryView として使用します (私の場合、ラベル、柔軟なセパレーター、ボタンがあります)。textFieldEditingChanged イベントで、このようにツールバーの一部を再構築します
@IBAction func textFieldEditingChanged(_ sender: UITextField) {
//get a reference to the toolbar
let toolBar = sender.inputAccessoryView as! UIToolbar
//create a new label and set size + other properties
toolbarLabel = UILabel(frame: CGRect(x: 0, y: 0, width: 40, height: 22))
toolbarLabel.text = mySpecificCalculatedString(sender.text!)
toolbarLabel.font = defaultFont(17)
toolbarLabel.adjustsFontSizeToFitWidth = true
let width = toolbarLabel.textRect(forBounds: CGRect(x: 0, y: 0, width: maxWidthForLabel, height: 0), limitedToNumberOfLines: 1).size.width
toolbarLabel.frame = CGRect(x: 0, y: 0, width: width, height: 22)
toolbarLabel.textColor = .black
toolbarLabel.tag = 666
//rebuild the specific tolbar item
let customView = UIBarButtonItem(customView: toolbarLabel)
toolBar.items![0] = customView
}
注: ラベルのテキストを変更するだけではうまくいきませんでした。再初期化する必要がありました。
それが役に立てば幸い。