某些 SF 符号会根据变量值改变其外观。使用 variableValue 属性,取值范围在 0.0 到 1.0 之间,以控制渲染的符号。需要 iOS 16.0 及以上版本和 SF Symbols 4.0 及以上版本。
🌐 Some SF Symbols alter their appearance based on a variable value. Use the variableValue prop with a value between 0.0 and 1.0 to control the rendered symbol. Requires iOS 16.0+ and SF Symbols 4.0+.
通过从 @expo/ui/swift-ui/modifiers 传递 symbolEffect 修饰符,为 SF 符号应用动画效果。默认情况下,此效果会连续运行。你也可以传递 value 来触发离散事件,每次更改时触发一次,或者传递 isActive 作为布尔切换,在 true 为真时运行此效果。需要 iOS 17.0 及更高版本。
🌐 Apply an SF Symbol effect to animate the symbol by passing a symbolEffect modifier from @expo/ui/swift-ui/modifiers. This effect runs continuously by default. You can also pass value for a discrete trigger that fires once per change, or isActive for a boolean toggle that runs the effect while true. Requires iOS 17.0 and later.
以下示例使用 value 在每次按下按钮时播放 bounce。从 worklet(或通过 scheduleOnUI)写入 state.value 以触发效果。
🌐 The following example uses value to play bounce on each button press. Write to state.value from a worklet (or via scheduleOnUI) to trigger the effect.
The color of the system image.
Can be a color name like '#ff00ff', 'red', 'blue', etc.
onPress
iOS
tvOS
Optional • Type: () => void
Callback triggered when the view is pressed.
size
iOS
tvOS
Optional • Type: number
The 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.
The name of the system image (SF Symbol).
For example: 'photo', 'heart.fill', 'star.circle'
uiImage
iOS
tvOS
Optional • Type: string
The 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.
variableValue
iOS16.0+
tvOS16.0+
Optional • Type: number
The 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+).