This documentation is available as Markdown for AI agents and LLMs. See the full Markdown index or append .md to any documentation URL.
Image
用于显示 SF Symbols 的 SwiftUI Image 组件。
如需跨平台使用,请参阅通用的
Icon— 它会根据平台渲染相应的原生组件。
Expo UI Image 使用 SwiftUI Image API 显示 SF Symbols。SF Symbols 是 Apple 提供的可配置符号库。


安装
If you are installing this in an existing React Native app, make sure to install expo in your project.
用法
基本 SF Symbol
自定义 SF Symbol
使用 assetName 属性显示作为符号集导入应用资源目录中的自定义 SF Symbol。
设置大小和颜色
设置变量值
某些 SF Symbols 会根据变量值改变外观。使用 variableValue 属性并传入 0.0 到 1.0 之间的值来控制渲染的符号。需要 iOS 16.0+ 和 SF Symbols 4.0+。
使用符号效果
通过传入来自 @expo/ui/swift-ui/modifiers 的 symbolEffect 修饰符,为符号应用 SF Symbol 效果并使其动起来。默认情况下,此效果会持续运行。你也可以传入 value,以便在每次值变化时触发一次效果;或者传入 isActive,通过布尔值开关控制效果在值为 true 时运行。需要 iOS 17.0 或更高版本。
以下示例使用 value,在每次按下按钮时播放 bounce。从 worklet 中(或通过 scheduleOnUI)向 state.value 写入值以触发效果。
以下示例使用 isActive 来切换持续运行的 breathe 动画。
API
import { Image } from '@expo/ui/swift-ui';
Component
Type: React.Element<ImageProps>
stringThe asset catalog name of a custom SF Symbol imported as a symbol set.
ColorValueThe color of the system image. Can be a color name like '#ff00ff', 'red', 'blue', etc.
numberThe fixed size of the system image in points. Does not scale with Dynamic
Type. Use the font modifier with textStyle for that. Ignored when a
font modifier is supplied.
SFSymbols7_0The name of the system image (SF Symbol). For example: 'photo', 'heart.fill', 'star.circle'
stringThe URI of the local image file to display. For example: 'file:///path/to/image.jpg' Performs a synchronous read operation that blocks the main thread.
numberThe variable value that alters the symbol's appearance. A number between 0.0 and 1.0. Only works with SF Symbols that support variable values (SF Symbols 4.0+).