Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to change DatePicker's texts color in SwiftUI?

I saw this question but it doesn't work in SwiftUI.

Changing text color of datepicker

I tried .forgroundColor and .accentColor but they don't change the texts' color.

like image 443
BabakHSL Avatar asked Sep 10 '25 10:09

BabakHSL


1 Answers

Using .colorInvert() and .colorMultiply(.white) will change the text color to white but won't work when the device is in Dark Mode. Instead, try this:

DatePicker("Date", selection: $selection)
    .colorScheme(.dark) // or .light to get black text
like image 125
Pranav Wadhwa Avatar answered Sep 13 '25 04:09

Pranav Wadhwa