Picker
受控的 SwiftUI 选择器,支持菜单、分段、单选组和内联样式。
#导入
从 github.com/egoist/quickgui/go/ui 导入 ui。
import (
"github.com/egoist/quickgui/go/native"
"github.com/egoist/quickgui/go/ui"
)#用法
func SwiftUiPickerExample() *native.Node {
value, setValue := ui.CreateSignal("list")
return ui.SwiftUI.Host(
ui.SwiftUIHostProps{MatchContents: true},
func() *native.Node {
return ui.SwiftUI.Picker(ui.SwiftUIPickerProps{
Selection: value,
Options: []ui.SwiftUIPickerOption{{Value: "list", Label: "List"}, {Value: "grid", Label: "Grid"}},
OnSelectionChange: func(next string, _ *native.Event) { setValue(next) },
})
},
)
}#API 参考
展开条目查看说明和完整签名。短横线表示声明中未记录默认值。
SwiftUI.Picker
查看源码ui.SwiftUI.Picker(props SwiftUIPickerProps) *native.NodeTestIDany—
Modifiersany—
Reffunc(*native.Node)—
Receives the retained native node after construction. Keep imperative work in event or lifecycle callbacks.
func(*native.Node)查看源码Selectionany—
Optionsany—
Labelany—
Stylestring—
Reusable layout, typography, color, and interaction-state styles. Build with ui.Style() and compose with Merge.
string查看源码