Open dimabiserov opened 5 years ago
Why not just create a custom cell and make the optionLabel
centered?
That would be helpful.
extension DropDown {
func setData(btn: UIButton?, dataSource: [String]){
guard let btn = btn else { return }
self.semanticContentAttribute = .unspecified
self.anchorView = btn
self.bottomOffset = CGPoint(x: 0, y: btn.bounds.height)
self.customCellConfiguration = { (index: Index, item: String, cell: DropDownCell) -> Void in
cell.optionLabel.textAlignment = .center
}
self.dataSource = dataSource
}
}
cityDropDown.setData(btn: cityBtn, dataSource: items)
cityDropDown.selectionAction = {[unowned self](index: Int, item: String) in
if index == 0 {
self.selectedCity = nil
return
}
self.cityTextField.text = item
self.selectedCity = cities[index-1]
}
Add this extension. This would be helpful.
extension DropDownCell { override open func awakeFromNib() { super.awakeFromNib() optionLabel.textAlignment = .center } }
yearDropDown.customCellConfiguration = { (index, item, cell) in cell.optionLabel.textAlignment = .center }
Please add a setting