当前位置:   article > 正文

HarmonyOS鸿蒙ArkTS滑动动画按钮_harmonyos滑动解锁arkts

harmonyos滑动解锁arkts

  1. @Entry
  2. @Component
  3. struct Index {
  4. @State metop: number = -80
  5. @State mecolor: string = '#ff1c80e9'
  6. @State mepan: boolean = false
  7. build () {
  8. Row () {
  9. Column () {
  10. Stack () {
  11. Column ()
  12. .width ( 200 )
  13. .height ( 70 )
  14. .backgroundColor ( this.mecolor )
  15. .shadow ( { radius: 30, color: '#212121' } )
  16. .border ( { radius: 50, style: BorderStyle.Solid } )
  17. Column ()
  18. .width ( 120 )
  19. .height ( 70 )
  20. .borderRadius ( 50 )
  21. .border ( { width: 2, color: '#ff756d6d', style: BorderStyle.Solid } )
  22. .linearGradient ( //渐变色
  23. {
  24. angle: 20,
  25. colors: [['rgba(134, 126, 126, 1.00)', 0.2], ["rgba(215, 204, 204, 1.00)", 0.8]]
  26. } )
  27. .margin ( { left: this.metop } )
  28. .onClick ( () => {
  29. animateTo ( { duration: 500 }, () => {
  30. this.mepan = !this.mepan
  31. if (this.mepan) {
  32. this.metop = 80
  33. this.mecolor = '#ffec0e6e'
  34. } else {
  35. this.metop = -80
  36. this.mecolor = '#ff1c80e9'
  37. }
  38. } )
  39. } )
  40. }
  41. }
  42. .width ( '100%' )
  43. }
  44. .height ( '100%' )
  45. }
  46. }

声明:本文内容由网友自发贡献,不代表【wpsshop博客】立场,版权归原作者所有,本站不承担相应法律责任。如您发现有侵权的内容,请联系我们。转载请注明出处:https://www.wpsshop.cn/w/小蓝xlanll/article/detail/688116
推荐阅读
相关标签
  

闽ICP备14008679号