跳到正文

DatePicker

受控的原生日期或日期时间选择器。

#导入

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

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

#用法

func SwiftUiDatePickerExample() *native.Node {
	value, setValue := ui.CreateSignal(float64(time.Now().UnixMilli()))
	return ui.SwiftUI.Host(
		ui.SwiftUIHostProps{MatchContents: true},
		func() *native.Node {
			return ui.SwiftUI.DatePicker(ui.SwiftUIDatePickerProps{
				Value:               value,
				DisplayedComponents: "dateAndTime",
				OnValueChange:       func(next float64, _ *native.Event) { setValue(next) },
			})
		},
	)
}

#API 参考

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

SwiftUI.DatePicker

查看源码
ui.SwiftUI.DatePicker(props SwiftUIDatePickerProps) *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)
查看源码
Valueany—

The current controlled value. Update application state from the change callback to accept a new value.

any
查看源码
Minany—

Lower bound of the accepted value.

any
查看源码
Maxany—

Upper bound of the accepted value.

any
查看源码
Labelany—

Visible native SwiftUI control label.

any
查看源码
DisplayedComponentsstring—

Chooses date, time, or combined date-and-time fields.

string
查看源码
Stylestring—

Reusable layout, typography, color, and interaction-state styles. Build with ui.Style() and compose with Merge.

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

Reports an accepted value change. Use the callback payload to update controlled state.

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