English 中文(简体)
• 如何改变“快速倡议”中的标本?
原标题:How to change DatePicker s texts color in SwiftUI?

我看到了这一问题,但是在快速倡议中并没有工作。

日期皮克的改动案文

I Trial .forgroundColor and .accentColor, but they do not t change the texts Rainbow.

问题回答

利用.colorInvert().colorMultiply(white),将案文改为白色,但在装置位于Darmo时,将赢得t工作。 而是尝试:

DatePicker("Date", selection: $selection)
    .colorScheme(.dark) // or .light to get black text

我只是简单地把cent子放在了身上,并发挥了作用。

@State private var date = Date()
DatePicker("Select a date",
           selection: $date, in: ...Date(), 
           displayedComponents: .date)
        .labelsHidden()
        .accentColor(.orange)

尝试:

var body: some View {
    Group {
        
        DatePicker(selection: $selected) {
            Text("Date")
        }
    
    .colorInvert()
        .colorMultiply(Color.blue)
    }
}

“entergraph

如果你利用一个背景图象,你可以这样做,使案文在光亮或暗淡的情况下显得白白。

struct PickerDate: View {
    @Environment(.colorScheme) var colorScheme
    @State var date: Date
    var body: some View {
        VStack {
            DatePicker("Record Date", selection: $date, in: ...Date(), displayedComponents: .date)
                .labelsHidden()
                .colorMultiply(colorScheme == .dark ? .black : .white)
                .colorInvert()
            }
        }
    }
}

我将视灯光和黑暗模式使用专用文字颜色。

extension View {
    @ViewBuilder func changeTextColor(_ color: Color) -> some View {
        if UITraitCollection.current.userInterfaceStyle == .light {
            self.colorInvert().colorMultiply(color)
        } else {
            self.colorMultiply(color)
        }
    }
}

样本如下。

DatePicker("Date", selection: $selection)
    .labelsHidden()
    .changeTextColor(.green)

I found applying this modifier to the DatePicker to be cleaner:

www.un.org/Depts/DGACM/index_spanish.htm 颜色到白色的部队

 .environment(.colorScheme, .dark)

www.un.org/Depts/DGACM/index_spanish.htm 颜色至黑暗的势力

 .environment(.colorScheme, .light)
DatePicker("DatePicker", selection: self.$date, displayedComponents: .hourAndMinute)
              .labelsHidden()
              .colorMultiply(Color.white)
              .colorInvert()

近期将进行校正。

colorInvert()一经开发就停止工作。

现在使用:

.preferredColorScheme(.dark)
.tint(baby.color.bgColor)
.colorMultiply(baby.color.bgColor)

But using .preferredColorScheme(.dark) in some cases affects all the view tones depending on the colors you are using.





相关问题
DatePicker minDate relative 1 month from start date

How do I set the #endDatePicker 1 month to the future of the selected date from #startDatePicker? I am not figuring this one out but I am sure it is easier than I am making it. Here is what I am ...

datepicker in JQuery UI Dialog shows calendar on dialog open

I have a JQuery modal dialog with 2 JQuery UI datepicker inputs. My problem is that when the dialog opens the calendar is already open on the page. I am not sure if this is because it is getting focus ...

jQuery datepicker to prevent past date

How do I disable past dates on jQuery datepicker? I looked for options but don t seem to find anything that indicates the ability to disable past dates. UPDATE: Thanks yall for the quick response. I ...

Silverlight DatePicker in DataGrid allow NULL dates

I have a DataGrid that has as one of its columns a DatePicker (for the editing template). Is there a way to keep this but still allow a user to enter in a NULL date?

How to reset a field when changing a date ui.datepicker.js

I m using ui.datepicker.js I have a form and when the date is changed I want that another field reset the status (this field is a dropdown select box). The case is the following: The user enter the ...

Not finding defaultDate in jQuery UI datepicker

I have a form text field that pulls a date from a database (in the format yyyy-mm-dd). <input class="" type="text" name="closingDate" id="closingDate" value="<?php echo $closingdate;?>" />...

热门标签