《鸿蒙开发-答案之书》帧动画

49 阅读1分钟
《鸿蒙开发-答案之书》帧动画

鸿蒙帧动画还挺简单的,可以看文档直接写

简单示例代码:

// 用帧动画
                      ImageAnimator()
                        .images([
                          {
                            src: $r('app.media.rc_voice_receive_play3'),
                            duration: 300,
                            width: 20,
                            height: 20,
                            top: 0,
                            left: 0
                          },
                          {
                            src: $r('app.media.rc_voice_receive_play2'),
                            duration: 300,
                            width: 20,
                            height: 20,
                            top: 0,
                            left: 0
                          },
                          {
                            src: $r('app.media.rc_voice_receive_play1'),
                            duration: 300,
                            width: 20,
                            height: 20,
                            top: 0,
                            left: 0
                          }
                        ])
                        .state(
                        AnimationStatus.Running)
                        .fixedSize(false)
                        .fillMode(FillMode.None)
                        .iterations(-1)

它是通过.state这属性来控制播放,停止播放的

有鸿蒙开发bug或者需求的可私信我,我每天都看私信的