当前位置:   article > 正文

鸿蒙Button组件如何设置渐变背景色_鸿蒙背景色渐变

鸿蒙背景色渐变

当我想给Button组件设置渐变的时候,却发现一直不生效,直到看到文档里说的“设置颜色渐变需先设置backgroundColor透明色。”

下面给个案例

  1. @Entry
  2. @Component
  3. @Preview
  4. struct Index {
  5. build() {
  6. Column() {
  7. Button('登录')
  8. .width(300)
  9. .margin({ top: 20, bottom: 20 })
  10. .height(48)
  11. .backgroundColor(Color.Transparent)// 设置颜色渐变需先设置backgroundColor为透明色。
  12. .linearGradient({
  13. angle: 180,
  14. colors: [[0x58B1FF, 0.0], [0x258FFF, 1]] })
  15. Button('test')
  16. .width(300)
  17. .height(50)
  18. .backgroundColor('#00000000')
  19. .linearGradient({
  20. angle: 90,
  21. colors: [[0xff0000, 0.0], [0x0000ff, 0.3], [0xffff00, 1.0]]
  22. })
  23. }.padding(30)
  24. }
  25. }

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

闽ICP备14008679号