#盲盒+码#HarmonyOS应用API手势方法-RotationGesture

鸿蒙时代
发布于 2022-11-30 10:26
6761浏览
0收藏

【本文正在参加「盲盒」+码有奖征文活动】(https://ost.51cto.com/posts/19288)
描述:用于触发旋转手势事件,触发旋转手势的最少手指为2指,最大为5指,最小改变度数为1度。

Api:从API Version 7开始支持

接口:RotationGesture(value?: { fingers?: number, angle?: number })

参数:
#盲盒+码#HarmonyOS应用API手势方法-RotationGesture-鸿蒙开发者社区
事件:
#盲盒+码#HarmonyOS应用API手势方法-RotationGesture-鸿蒙开发者社区
示例代码:

@Entry
@Component
struct RotationGestureExample {
  @State angle: number = 0;
  @State rotateValue: number = 0;

  build() {
    Column() {
      Column() {
        Text('RotationGesture angle:' + this.angle).fontSize(20)
      }
      .height(200)
      .width(300)
      .padding(20)
      .border({ width: 3 })
      .margin(80)
      .rotate({ angle: this.angle })
      // 双指旋转触发该手势事件
      .gesture(
      RotationGesture()
        .onActionStart((event: GestureEvent) => {
          console.info('Rotation start');
        })
        .onActionUpdate((event: GestureEvent) => {
          this.angle = this.rotateValue + event.angle;
        })
        .onActionEnd(() => {
          this.rotateValue = this.angle;
          console.info('Rotation end');
        })
      )
    }.width('100%')
  }
}

  • 1.
  • 2.
  • 3.
  • 4.
  • 5.
  • 6.
  • 7.
  • 8.
  • 9.
  • 10.
  • 11.
  • 12.
  • 13.
  • 14.
  • 15.
  • 16.
  • 17.
  • 18.
  • 19.
  • 20.
  • 21.
  • 22.
  • 23.
  • 24.
  • 25.
  • 26.
  • 27.
  • 28.
  • 29.
  • 30.
  • 31.
  • 32.
  • 33.
  • 34.
  • 35.

示例效果:
#盲盒+码#HarmonyOS应用API手势方法-RotationGesture-鸿蒙开发者社区
代码地址:(https://gitee.com/jltfcloudcn/jump_to/tree/master/TapGesture)

标签
RotationGesture.docx 31.54K 13次下载
已于2022-11-30 10:27:05修改
2
收藏
回复
举报
2


回复
    相关推荐