本文へスキップ

Button

テキスト、SF Symbol、セマンティックロール、押下処理に対応したネイティブ SwiftUI Button です。

#インポート

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.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)
ソースを見る
Labelany—

Visible native SwiftUI control label.

any
ソースを見る
SystemImagestring—

SF Symbols name displayed with a SwiftUI button label.

string
ソースを見る
Rolestring—

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

string
ソースを見る
OnPressfunc(*native.Event)—

Runs when the native SwiftUI button is activated.

func(*native.Event)
ソースを見る
Targetstring—

Destination associated with this navigation or link part.

string
ソースを見る
ChildrenComponent—

Content mounted inside the component. Compound child callbacks run after the parent context exists.

Component
ソースを見る