I use picker view in textfield input view. it works perfectly but when I selected the second row then it changes the color red and then I close picker and when I open second-time picker color of the selected row is not changed but it's not working only for second row .other row works perfectly.
Here is MyCode
func pickerView(_ pickerView: UIPickerView, viewForRow row: Int, forComponent component: Int, reusing view: UIView?) -> UIView {
var selectedRow = String()
selectedRow = capicityArray[row]
let pickerLabel = UILabel()
if pickerView.selectedRow(inComponent: component) == row {
pickerLabel.attributedText = NSAttributedString(string: selectedRow, attributes: [NSAttributedStringKey.font:GlobalFont.Font_GillSansStd(fontsize: 26), NSAttributedStringKey.foregroundColor: GlobalColor.RED_THEME])
} else {
pickerLabel.attributedText = NSAttributedString(string: selectedRow, attributes: [NSAttributedStringKey.font:GlobalFont.Font_GillSansStd(fontsize: 22), NSAttributedStringKey.foregroundColor: GlobalColor.Color153])
}
pickerLabel.isOpaque = true
pickerLabel.textAlignment = .center
return pickerLabel
}
output :
When First time Selected 2nd row
then close picker and open picker again the
the second-row not change color red