UI弹出呈现
popover
在视图旁边显示气泡。
popover(options) 在被修饰的视图旁边显示气泡,点击外部区域会关闭。在 iPhone 上同样以气泡显示,不会变成 sheet。
import { Button, Modifier, Text, useState } from "onescript/views"
function Hint() {
const [shown, setShown] = useState(false)
return (
<Button
action={() => setShown(true)}
modifier={Modifier.popover({
isPresented: shown,
onDismiss: () => setShown(false),
arrowEdge: "top",
content: (
<Text modifier={Modifier.padding(16)}>
长按条目可以重新排序
</Text>
),
})}
>
提示
</Button>
)
}| 参数 | 类型 | 说明 |
|---|---|---|
isPresented | boolean | 是否显示。 |
onDismiss | () => void | 用户关闭时调用,需在其中把 isPresented 设为 false。 |
content | ViewChild | 气泡内容。 |
arrowEdge | "top" | "bottom" | "leading" | "trailing" | 可选。箭头所在的边,不传时由系统决定。 |
气泡按内容的理想尺寸显示,较长的文本不会自动换行。请用 frame 给内容设置宽度。
How is this guide?
最后更新于