swiftswiftui

How can I create a button with image in SwiftUI?


I created a button in SwiftUI with these line of codes:

Button(action: {
    print("button pressed")
}) {
    Image("marker")
}

but marker image automatically changes to blue color.

I want to use original image in button.

this is original marker.png:

enter image description here

but SwiftUI changes it to this:

enter image description here

I remember we have tintColor or something like this in UIButton, but I can't find it in SwiftUI.


Solution

  • Go to the image and change the Render As "Original Image" enter image description here