HarmonyOS 鸿蒙 ArkTS ArkUI 路径动画设置

@Entry
@Component
struct Shouye {
  @State message: string = 'Hello'
  @State toggle: boolean = true
  onPageShow (): void {
    animateTo ( {
      duration: 3000,
      iterations: -1,
      curve:Curve.Linear

    }, () => {
      this.toggle = !this.toggle
    } )

  }
  build () {
    Row () {
      Column () {
        Text ( this.message )
          .fontSize ( 50 )
          .fontWeight ( FontWeight.Bold )
          .motionPath({ path: 'Mstart.x start.y L300 1000 L300 500 L300 800 L300 1000 Lend.x end.y', from: 0.0, to: 1.0, rotatable: true })
      }
      .width('100%').height('100%').alignItems(this.toggle ? HorizontalAlign.Start : HorizontalAlign.Center)
    }
    .height ( '100%' )
  }

}

参考

名称

参数

描述

motionPath

{

path: string,

from?: number,

to?: number,

rotatable?: boolean

}

设置组件的运动路径。

- path:位移动画的运动路径,使用svg路径字符串。path中支持使用start和end进行起点和终点的替代,如:'Mstart.x start.y L50 50 Lend.x end.y Z',更多说明请参考。

- from:运动路径的起点。

取值范围:[0, 1]

- to:运动路径的终点。

取值范围:[0, 1]

- rotatable:是否跟随路径进行旋转。

HorizontalAlign

名称

描述

Start

按照语言方向起始端对齐。

Center

居中对齐,默认对齐方式。

End

按照语言方向末端对齐。

学习交流

点击下方名片,拉您 

相关推荐

最近更新

  1. docker php8.1+nginx base 镜像 dockerfile 配置

    2024-02-13 09:16:02       94 阅读
  2. Could not load dynamic library ‘cudart64_100.dll‘

    2024-02-13 09:16:02       100 阅读
  3. 在Django里面运行非项目文件

    2024-02-13 09:16:02       82 阅读
  4. Python语言-面向对象

    2024-02-13 09:16:02       91 阅读

热门阅读

  1. Tokitsukaze and Short Path (plus)-牛客寒假训练营(二)

    2024-02-13 09:16:02       60 阅读
  2. 使用Nacos实现服务发现

    2024-02-13 09:16:02       54 阅读
  3. git入门

    2024-02-13 09:16:02       48 阅读
  4. 347. 前 K 个高频元素

    2024-02-13 09:16:02       56 阅读
  5. vue3 封装一个通用echarts组件

    2024-02-13 09:16:02       63 阅读
  6. 速盾:cdn集群防御空间dns服务器

    2024-02-13 09:16:02       47 阅读
  7. 深入了解Redis的过期策略和内存淘汰机制

    2024-02-13 09:16:02       44 阅读
  8. AutoSAR(基础入门篇)8.5-C/S原理进阶

    2024-02-13 09:16:02       42 阅读
  9. leetcode 153

    2024-02-13 09:16:02       50 阅读
  10. Apache POI的介绍以及使用示例

    2024-02-13 09:16:02       50 阅读
  11. 学习记录691@spring面试之bean的作用域

    2024-02-13 09:16:02       51 阅读