我正在尝试将标题放在UIPickerView工具栏中。以下是我可以选择的最接近的年份(年份)。
下面是我的代码。
let toolBar = UIToolbar()
toolBar.sizeToFit()
let doneButton = UIBarButtonItem(title: "Done", style: .plain, target: self, action: #selector(ViewController.dismissKeyboard))
let spaceButton = UIBarButtonItem(barButtonSystemItem: .flexibleSpace, target: nil, action: nil)
let yearButton = UIBarButtonItem(title: "Year", style: .plain, target: self, action: nil)
toolBar.setItems([doneButton,spaceButton, yearButton, spaceButton], animated: false)
toolBar.isUserInteractionEnabled = true
seasonTextField.inputAccessoryView = toolBar
任何帮助将不胜感激。