Button
原生 SwiftUI 按钮,支持文本、SF Symbol、语义角色和按下处理。
#导入
从 github.com/egoist/quickgui/go/ui 导入 ui。
import (
"fmt"
"github.com/egoist/quickgui/go/native"
"github.com/egoist/quickgui/go/ui"
)#用法
func SwiftUiButtonExample() *native.Node {
return ui.SwiftUI.Host(
ui.SwiftUIHostProps{MatchContents: true},
func() *native.Node {
return ui.SwiftUI.Button(ui.SwiftUIButtonProps{
Label: "Save",
SystemImage: "checkmark",
OnPress: func(*native.Event) { fmt.Println("Saved") },
Modifiers: []ui.SwiftUIModifier{ui.SwiftUI.ButtonStyle("borderedProminent")},
})
},
)
}#API 参考
展开条目查看说明和完整签名。短横线表示声明中未记录默认值。
SwiftUI.Button
查看源码ui.SwiftUI.Button(props SwiftUIButtonProps, children ...any) *native.NodeTestIDany—
Modifiersany—
Reffunc(*native.Node)—
Receives the retained native node after construction. Keep imperative work in event or lifecycle callbacks.
func(*native.Node)查看源码Labelany—
SystemImagestring—
Rolestring—
OnPressfunc(*native.Event)—
Targetstring—
ChildrenComponent—
Content mounted inside the component. Compound child callbacks run after the parent context exists.
Component查看源码