I was also surprised by the tap area being larger than the frame of the button.
By accident I found that if you insert a UIKit view behind the SwiftUI button then the tap area on the button will behave as expected. No idea if this is bug or not.
struct ContentView: View {
var body: some View {
ZStack {
UIKitView()
.ignoresSafeArea()
Button("Hell, world") {}
.border(Color.black)
}
}
}
#Preview {
ContentView()
}
struct UIKitView: UIViewRepresentable {
func makeUIView(context: Context) -> UIView {
return UIView()
}
func updateUIView(_ view: UIView, context: Context) {}
}