ArkUI中如何给Image组件设置自动重复旋转动画?

设置image组件以图片中心点为原点1.6秒一次自动旋转

阅读 1.1k
1 个回答

请参考如下代码:

@Entry
@Component
struct ImageAnimateToRotate{
@State message: string = 'Hello World';
@State imageAngle: number = 0

build() {
Column() {
Image($r('app.media.startIcon')).width(200).height(200)
.rotate({ z: 1, angle: this.imageAngle })
.onAppear(() => {
animateTo({ duration: 5000, iterations: -1 }, () => {
this.imageAngle = 360
})
})
}
.height('100%')
.width('100%')
}
}
撰写回答
你尚未登录,登录后可以
  • 和开发者交流问题的细节
  • 关注并接收问题和回答的更新提醒
  • 参与内容的编辑和改进,让解决方法与时俱进