Swift DatePickerのラベルの色を変えるサンプル
環境
Swift
構文
DatePicker(“", selection: $date)
.foregroundColor(labelColor)
DatePickerにforegroundColor修飾子を付与します。
foregrounColorの引数にラベルの色を指定します。
DatePickerのラベルの色を変えるには、foregroundColor修飾子を使います。
使用例
struct ContentView: View {
@State var date = Date()
var body: some View {
VStack{
DatePicker("日付の選択", selection: $date)
.foregroundColor(Color.red)
.padding()
}
}
}