Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to set default label color based on dark/light mode (in Swift)

I am trying to update my iOS app for dark mode, but am having trouble with setting the dark mode colors in code. Upon editing a UITextView, the color I want the text color to be white in dark mode, and black in light mode (which is default label color), but to my knowledge I do not know how to write this in code, how do I do it?

extension AddCardsVC: UITextViewDelegate {
    func textViewDidBeginEditing(_ textView: UITextView) {
        if #available(iOS 13.0, *) {
            definitionInput.textColor = UIColor.(need default label color)
        } else {
            definitionInput.textColor = UIColor.black
        }
        if(definitionInput.text == "organizing items into familiar, manageable units; often occurs automatically"){
            definitionInput.text = ""
        }
    }

}
like image 949
tHatpart Avatar asked Nov 29 '22 21:11

tHatpart


1 Answers

Or use UIColor.label to get system label color.

like image 66
G.Song Avatar answered Dec 02 '22 11:12

G.Song