我正在为 iOS17 应用程序构建一个小部件,下面是小部件的按钮代码
var body: some View {
if #available(iOS 17.0, *) {
Button(intent: TodoCheckInIntent(todoId: todo.id)) {
Text("hello")
}
.frame(width: 65, height: 21)
} else {
todoSubView
}
}
在ios17上运行后是这样的。该按钮具有有线蓝色背景。 我的问题是如何删除有线蓝色背景。
感谢您的回答
我对按钮使用了
.padding(0)
,但没有任何效果
那是因为默认的按钮样式。您应该在按钮上使用
.buttonStyle(.plain)
:
Button(intent: TodoCheckInIntent(todoId: todo.id)) {
Text("hello")
}
.frame(width: 65, height: 21)
.buttonStyle(.plain) // 👈 Here