UI视图
Label
将标题与图标组合在一起。
按系统惯例排列的“图标 + 标题”。List、Menu、工具栏和按钮会自动调整 Label 的外观。children 是标题。
import { Label } from "onescript/views"
<Label symbol="star.fill">收藏</Label>| Prop | Type | 说明 |
|---|---|---|
symbol | string | 作为图标的 SF Symbol 或 Pika 图标名。 |
source | "sf" | "pika" | symbol 的图标来源,默认 "sf"。 |
icon | ViewChild | 作为图标的任意视图,例如 Image。 |
children | ViewChild | 标题。 |
symbol 与 icon 必须且只能提供一个;source 只能与 symbol 一起使用。
自定义图标
import { Image, Label, Modifier } from "onescript/views"
import avatar from "./assets/avatar.png"
<Label
icon={
<Image
url={new URL(avatar)}
resizable
modifier={Modifier
.scaledToFit()
.frame({ width: 20, height: 20 })}
/>
}
>
个人资料
</Label>用 labelStyle 可以只显示标题或只显示图标。也支持修饰符。可在 App、Action 和 Widget 视图中使用。
How is this guide?
最后更新于