在Swift 3中,我无法在pickerview中设置工具栏
pickerFilter?.inputAccessoryView = barAccessory
错误是inputAccessoryView是仅获取属性。
当我是Pickerview中的addsubview时。工具栏已显示,但完成按钮不可单击
有什么办法吗?
最佳答案
let flexiblespace = UIBarButtonItem(barButtonSystemItem:.flexibleSpace , target: nil, action: nil)
let btnDone = UIBarButtonItem(barButtonSystemItem: .done, target: self, action: #selector(self.donePresed))
let barAccessory = UIToolbar(frame: CGRect(x: 0, y: 0, width: viewPicker.frame.size.width, height: 44))
barAccessory.barStyle = .default
barAccessory.isTranslucent = true
barAccessory.items = [flexiblespace,btnDone]
viewPicker.addSubview(pickerDrpDown!)
viewPicker.addSubview(barAccessory)