I am making an app where I have 4 tabs, the last tab is used to change to dark mode (changing the label color, BG color, keyboard color and pickerView color). The func is where I change the color. Everything works except the pickerView isn't changing color so thats what I need help with.
override func viewWillAppear(_ animated: Bool) {
if UserDefaults.standard.integer(forKey: "dark") == 1{
self.view.backgroundColor = UIColor.darkGray
UITextField.appearance().keyboardAppearance = .dark
textField.backgroundColor = UIColor.white
textField.textColor = UIColor.black
textField2.textColor = UIColor.black
textField2.backgroundColor = UIColor.white
label.textColor = UIColor.white
label.textColor = UIColor.white
labelIN1.textColor = UIColor.white
func pickerView(_ pickerView: UIPickerView, attributedTitleForRow row: Int, forComponent component: Int) -> NSAttributedString? {
let titleData = list[row]
let myTitle = NSAttributedString(string: titleData, attributes: [NSForegroundColorAttributeName:UIColor.black])
return myTitle
}
}else{
self.view.backgroundColor = UIColor.white
UITextField.appearance().keyboardAppearance = .light
textField.backgroundColor = UIColor.white
textField.textColor = UIColor.black
textField2.textColor = UIColor.black
textField2.backgroundColor = UIColor.white
label.textColor = UIColor.black
label.textColor = UIColor.black
labelIN1.textColor = UIColor.black
func pickerView(_ pickerView: UIPickerView, attributedTitleForRow row: Int, forComponent component: Int) -> NSAttributedString? {
let titleData = list[row]
let myTitle = NSAttributedString(string: titleData, attributes: [NSForegroundColorAttributeName:UIColor.white])
return myTitle
}
}
}