【发布时间】:2021-03-02 07:38:59
【问题描述】:
我正在尝试使用 SwiftUI 为 MacOS 应用程序制作自定义按钮,但是,我似乎无法调整按钮区域的大小,并且按钮的颜色似乎无法更改。我在网上找到的所有示例都说使用 .frame 或 .padding 来设置宽度和高度,但这不会改变按钮的形状。有没有其他人在开发 MacOS 应用程序时遇到过这种情况? Image of button here
struct customButton: View {
var body: some View {
Button(action: {
print("Delete button tapped!")
}) {
HStack {
Image(systemName: "trash")
.resizable()
.scaledToFit()
.imageScale(.large)
Text("Delete")
}
.padding()
.background(
Capsule().strokeBorder(Color.white, lineWidth: 1.25)
)
}
.accentColor(Color.white)
}
}
【问题讨论】: