Skip to content

动画

用 animate 关键字为属性声明动画,即可为属性变更添加动画: 此后该属性的每次变化都会播放动画——无论它来自绑定、状态变化,还是你的业务逻辑。

export component Example inherits Window {
preferred-width: 100px;
preferred-height: 100px;
background: area.pressed ? blue : red;
animate background {
duration: 250ms;
}
area := TouchArea {}
}
slint

这会在颜色属性变化时为其播放 250ms 的动画。

用 delay、duration、iteration-count、easing、direction 和 enabled 微调动画, 并让多个属性共用同一个动画:

animate x, y { duration: 100ms; easing: ease-out-bounce; }
slint

语言参考中的动画章节描述了每个参数, easing 类型列出了可用的缓动曲线。


© 2026 SixtyFPS GmbH