@Component
export struct ResultDisplay {
@State fontSize: number = 14;
/// build 略同...
startAnimation(): void {
let param: AnimateParam = { curve: Curve.EaseIn, duration: 500 };
this.getUIContext()?.animateTo(param, () => this.onEvent());
}
onEvent(): void {
this.fontSize = 42;
}
}
this.getUIContext()?.animateTo() 会让fontSize 在 500s 内由14到42变化。