SwiftUIでButton内の画像の色を変えない


SwiftUIでButton内の画像の色を変えない方法です。 デフォルトのままだと以下の画像のように色が青く変わってしまいます。

ButtonColor

renderingMode(.original) と設定することで、元の画像の色が表示されました。

ButtonColor

ContentView.swift

import SwiftUI

struct ContentView: View {
    
    var body: some View {
        Button(action: {
            print("Tapped")
        }) {
            Image("icon")
                .resizable()
                .renderingMode(.original)
                .frame(width: 32, height: 32)
            
            Text("Tap Me!!")
                .foregroundColor(Color.black)
        }
    }
}

struct ContentView_Previews: PreviewProvider {
    static var previews: some View {
        ContentView()
    }
}