我阅读了关于该问题的类似文章question。但是那只能使用.padding()
来扩大按钮的大小。快照中的红色区域是可点击区域。
无法删除SwiftUI.framework插入到屏幕边缘的尾随填充(我认为)。这导致在屏幕右边缘的任何轻击都无法触发按钮动作。如何使可点击区域超出按钮大小?这样用户可以更轻松地点击该按钮。
谢谢。
.navigationBarItems(trailing:
Button(action: {
self.context.isSheetDisplay = true
}, label: {
Image(systemName: "square.and.pencil")
.font(.system(size: 20))
})
.padding([.leading, .top, .bottom])
.background(Color.red)
)
将填充物放在按钮内,如下所示
Button(action: {
self.context.isSheetDisplay = true
}, label: {
Image(systemName: "square.and.pencil")
.font(.system(size: 20))
.padding([.leading, .top, .bottom]) // << here !!
})