Changing text color of datepicker

前端 未结 8 2343
鱼传尺愫
鱼传尺愫 2020-12-01 15:57

Is it any way to change text color of datepicker in iOS8? I\'ve that it isn\'t possible in iOS7 and prior, something changed in 8th version?

For example I\'ve found

相关标签:
8条回答
  • 2020-12-01 16:37

    I found a way that wasnt listed here or in the other thread. https://stackoverflow.com/a/59838215/4266735

    I ran into a similar issue with the latest SwiftUI / Swift 5 on XCode 11. All of the options above did not work and the DatePicker either stayed black text or crashed.

    In your SwiftUI file set init() before var body

    init() {
        UIDatePicker.appearance().backgroundColor = .clear
    }
    

    Then in your var body view do this

    DatePicker(selection: $dob, in: ...Date(), displayedComponents: .date) {
       Text("Select Date")
    }.colorInvert()
    

    That inverted the black text to be white using the iOS Dark Theme. Looks/works great. Hope this helps.

    0 讨论(0)
  • 2020-12-01 16:38

    I've changed text color through inspector (see below)

    0 讨论(0)
提交回复
热议问题