本文へスキップ

Toggle

制御されたネイティブ SwiftUI オン/オフスイッチです。

#インポート

github.com/egoist/quickgui/go/ui から ui をインポートします。

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

#使い方

func SwiftUiToggleExample() *native.Node {
	on, setOn := ui.CreateSignal(true)
	return ui.SwiftUI.Host(
		ui.SwiftUIHostProps{MatchContents: true},
		func() *native.Node {
			return ui.SwiftUI.Toggle(ui.SwiftUIToggleProps{
				IsOn:         on,
				Label:        "Notifications",
				OnIsOnChange: func(next bool, _ *native.Event) { setOn(next) },
			})
		},
	)
}

#API リファレンス

項目を展開すると説明と完全なシグネチャが表示されます。ダッシュは宣言に既定値が記載されていないことを示します。

SwiftUI.Toggle

ソースを見る
ui.SwiftUI.Toggle(props SwiftUIToggleProps) *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)
ソースを見る
IsOnany—

Controlled SwiftUI toggle value.

any
ソースを見る
Labelany—

Visible native SwiftUI control label.

any
ソースを見る
OnIsOnChangefunc(bool, *native.Event)—

Reports the value accepted by the native SwiftUI toggle.

func(bool, *native.Event)
ソースを見る