どうも、ちょげ(@chogetarou)です。
Buttonのテキストカラーを変える方法を紹介します。
方法

Buttonの文字色を変えるには、foregroundColor修飾子を使います。
まず、ButtonにforegroundColor修飾子を付与します。
そして、foregroundColor修飾子の引数にテキストカラーを指定します。
Button(・・・)
.foregroundColor(color) //引数に文字色を指定
引数に文字色を指定したforegroundColor修飾子をButtonに付与することで、Buttoの文字色を変えることが出来ます。
使用例

struct ContentView: View {
var body: some View {
VStack {
Button("Button") {
print("Tap")
}
.padding(20)
.foregroundColor(.white)
.background(.blue)
}
}
}
コメント