「SwiftUI」foregroundColorでアイコンの色を変える
書式
.foregroundColor(Color.カラー名)
foregroundColor関数を利用してアイコンの色を変えます。
使用例
struct ContentView: View {
var body: some View {
Image(systemName: "logo.circle")
.foregroundColor(Color.red)
}
}
struct ContentView: View {
var body: some View {
Image(systemName: "logo.circle")
.foregroundColor(Color.red)
}
}
struct ContentView: View { var body: some View { Image(systemName: "logo.circle") .foregroundColor(Color.red) } }
結果
アイコンの色を赤に変えます。