ios – SwiftUI Button with Image frame is larger than image


I am trying to make a button with an image in SwiftUI. The size of the image is 200×266. I want to use this in a button which is 100×133. No matter what I do, SwiftUI puts a frame around it, which is larger than the image, and the whole area inside the frame is clickable (not just the image). I tried adding a frame to the button, different options of image scaling, nothing helps. What am I doing wrong?

Here is the code:

                Button(action: {
                }) {
                    Image("DelOff")
                        .resizable()
                        .scaledToFit()
                        .frame(width: 100, height:133)
                    
                }
                .border(Color.black)
                .buttonStyle(.plain)
        }

And this what I get:
Button in Playground

Latest articles

spot_imgspot_img

Related articles

Leave a reply

Please enter your comment!
Please enter your name here

spot_imgspot_img