跳到正文

SegmentedControl

原生分段选择器,支持值选择和中性的 Xcode 风格标签页角色。

#导入

从 github.com/egoist/quickgui/go/ui 导入 ui。

import (
	"github.com/egoist/quickgui/go/native"
	"github.com/egoist/quickgui/go/ui"
)

#用法

func SwiftUiSegmentedControlExample() *native.Node {
	value, setValue := ui.CreateSignal("list")
	return ui.SwiftUI.Host(
		ui.SwiftUIHostProps{MatchContents: true},
		func() *native.Node {
			return ui.SwiftUI.SegmentedControl(ui.SwiftUISegmentedControlProps{
				Selection:         value,
				Options:           []ui.SwiftUIPickerOption{{Value: "list", Label: "List"}, {Value: "grid", Label: "Grid"}},
				OnSelectionChange: func(next string, _ *native.Event) { setValue(next) },
			})
		},
	)
}

#API 参考

展开条目查看说明和完整签名。短横线表示声明中未记录默认值。

SwiftUI.SegmentedControl

查看源码
ui.SwiftUI.SegmentedControl(props SwiftUISegmentedControlProps) *native.Node
TestIDany—

Stable identifier for native automation and tests.

any
查看源码
Modifiersany—

Ordered SwiftUI view modifiers applied to the hosted control.

any
查看源码
Reffunc(*native.Node)—

Receives the retained native node after construction. Keep imperative work in event or lifecycle callbacks.

func(*native.Node)
查看源码
Selectionany—

Controlled selection for a table, native picker, or color control.

any
查看源码
Optionsany—

Ordered native picker options.

any
查看源码
Labelany—

Visible native SwiftUI control label.

any
查看源码
Rolestring—

Accessibility role override. Prefer the component’s built-in semantics.

string
查看源码
OnSelectionChangefunc(string, *native.Event)—

Reports the selected native picker option or color.

func(string, *native.Event)
查看源码