HarmonyOS Image配置的图片如何旋转?

如题:HarmonyOS Image配置的图片如何旋转?

阅读 607
1 个回答

可参考示例如下:

import { curves } from '@kit.ArkUI'

@Entry
@Component
struct Page030 {
  @State rotateValue: number = 0

  build() {
    Column() {
      Button('测试').onClick(() => {
        this.rotateValue = 360
      })
      Image($r("app.media.app_icon"))
        .width('200lpx')
        .height('200lpx')
        .rotate({ angle: this.rotateValue })
        .animation(this.rotateValue != 0 ? {
          duration: 2000,
          curve: curves.springMotion(),
          playMode: PlayMode.Normal,
          onFinish: (() => {
            console.info('----onFinish this.rotateValue', this.rotateValue)
            if (this.rotateValue == 360) {
              this.rotateValue = 0
            }
          })
        } : undefined)
    }
    .width('100%')
    .height('100%')
  }
}
撰写回答
你尚未登录,登录后可以
  • 和开发者交流问题的细节
  • 关注并接收问题和回答的更新提醒
  • 参与内容的编辑和改进,让解决方法与时俱进