Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

iOS Text Field does not work in Dark Mode

I have a very simple page in my storyboard to create/edit a note. It's a basic ViewController, and the only content of the view is a UITextField for the title of the note, and a UITextView for the body of it, positioned right below.

Both the body field and the title field use the default label color, as well as the default white background (which should switch to black in dark mode). I'm completely lost as to why the UITextField does not switch automatically. Am I missing something about these elements? Screenshot below:

enter image description here

like image 784
OstrichGlue Avatar asked Oct 15 '25 23:10

OstrichGlue


1 Answers

The default value of this property is UIUserInterfaceStyle.unspecified, which causes the view to inherit the interface style from a parent view or view controller. If you assign a different value, the new style applies to the view and all of the subviews owned by the same view controller.

if #available(iOS 13.0, *) {
        txtUsername.overrideUserInterfaceStyle = .light
    } else {
        // Fallback on earlier versions
    }
like image 150
thevikasnayak Avatar answered Oct 18 '25 16:10

thevikasnayak