JIANG
JIANG

Reputation: 1887

Can't Change The DatePicker Font Color

I have two datepickers, but the font color is white even I set it to be black. Makes them hard to read.

                DatePicker(selection: $fromDate.onChange(self.setFromDate(fromdate:)), in: ...Date(), displayedComponents: .date) {
                    Text("From")
                        .font(.body)
                        .foregroundColor(.black)
                        .fixedSize()
                }
                DatePicker(selection: $toDate.onChange(self.setToDate(todate:)), in: ...Date(), displayedComponents: .date) {
                    Text("To")
                        .foregroundColor(.black)
                        .font(.body)
                        .fixedSize()
                }

enter image description here

Upvotes: 0

Views: 176

Answers (1)

Raja Kishan
Raja Kishan

Reputation: 19014

You can use .accentColor()

DatePicker(selection: $fromDate.onChange(self.setFromDate(fromdate:)), in: ...Date(), displayedComponents: .date) {
                  Text("From")
                      .font(.body)
                      .foregroundColor(.black)
                      .fixedSize()
}
.accentColor(Color.black)

Upvotes: 2

Related Questions