弹出展示Presentation
popoverpopover
在当前上下文附近展示轻量补充内容,适合提示、说明或小型工具面板。Shows lightweight contextual content near the trigger.
中级Intermediate • 4 分钟4 min
更新于Updated Apr 22, 2026
上下文弹窗Contextual Popover
popover 通常锚定在触发控件附近,用于展示轻量级上下文内容。popover is usually anchored near its trigger and shows lightweight contextual content.
展示 PopoverShow a Popover
swift
1@State private var showingTip = false23Button("Show Tip") {4 showingTip.toggle()5}6.popover(isPresented: $showingTip) {7 Text("Use popover for lightweight context.")8 .padding()9}