HarmonyOS 如何实现券组件的挖空样式

如何实现券组件的挖空样式

HarmonyOS
2024-12-20 15:08:32
浏览
收藏 0
回答 1
回答 1
按赞同
/
按时间
zbw_apple

参考demo:

// xxx.ets
@Entry
@Component
struct ShapeExample {
  private borderWdth: number = 2;
  private radiusWdthSmall: number = 8
  private radiusWdthBig: number = 10
  build() {
    Column({ space: 10 }) {
      Row(){
        Column(){
          Stack(){
            Column(){
              Text('618')
                .fontSize(10)
                .fontColor('#fff')
            }
            .position({
              x: 0,
              y: 0,
            })
            .width(40)
            .backgroundColor('rgba(255,255,255,0.3)')
            .borderRadius({
              topLeft: this.radiusWdthBig,
              bottomRight: this.radiusWdthBig,
            })
            Column(){
              Text(){
                Span('¥')
                  .fontSize(16)
                  .fontColor('#fff')
                Span('20')
                  .fontSize(20)

              }
              .fontColor('#fff')
              .fontWeight(FontWeight.Bold)
              Text(){
                Span('无门槛使用')
                  .fontSize(10)
                  .fontColor('#fff')
              }
            }

          }
          .width('100%')
          .height('100%')
        }
        .width(80)
        .height(80)
        .border({
          width: { left: this.borderWdth, right: 0, top: this.borderWdth, bottom: this.borderWdth },
          color: '#f00',
        })
        .borderRadius({
          topLeft: this.radiusWdthBig,
          bottomLeft: this.radiusWdthBig,
        })
        Column(){
          Row()
            .width(this.radiusWdthSmall)
            .height(this.radiusWdthSmall)
            .backgroundColor('#fff')
            .borderRadius({
              bottomLeft: this.radiusWdthSmall
            })
            .border({
              width: { left: this.borderWdth, right: 0, top: 0, bottom: this.borderWdth },
              color: '#f00',
            })
          Row()
            .width(this.radiusWdthSmall)
            .height(`calc(100% - ${2 * this.radiusWdthSmall}vp)`)
            .border({
              color: '#ccc',
              width: { left: 0, right: 1, top: 0, bottom: 0 },
              style: {
                right: BorderStyle.Dotted
              }
            })
          Row()
            .width(this.radiusWdthSmall)
            .height(this.radiusWdthSmall)
            .backgroundColor('#fff')
            .borderRadius({
              topLeft: this.radiusWdthSmall
            })
            .border({
              width: { left: this.borderWdth, right: 0, top: this.borderWdth, bottom: 0 },
              color: '#f00'
            })
        }
        .height('100%')
        .justifyContent(FlexAlign.SpaceBetween)
        Column(){
          Column()
            .width(this.radiusWdthSmall)
            .height(this.radiusWdthSmall)
            .backgroundColor('#fff')
            .borderRadius({
              bottomRight: this.radiusWdthSmall
            })
            .border({
              width: { left: 0, right: this.borderWdth, top: 0, bottom: this.borderWdth },
              color: '#f00',
            })
          Column()
            .width(this.radiusWdthSmall)
            .height(this.radiusWdthSmall)
            .backgroundColor('#fff')
            .borderRadius({
              topRight: this.radiusWdthSmall
            })
            .border({
              width: { left: 0, right: this.borderWdth, top: this.borderWdth, bottom: 0 },
              color: '#f00',
            })
        }
        .height('100%')
        .justifyContent(FlexAlign.SpaceBetween)
        Column(){
          Row(){
            Column(){
              Text(){
                Span('新客专享券')
                  .fontSize(12)

              }
              .fontColor('#fff')
              .margin({
                bottom: 6
              })
              Text(){
                Span('有效期至2024-8-30')
                  .fontSize(10)
                  .fontColor('#ddd')
              }
            }
            Stack(){
              Button('领取')
                .backgroundColor('#f00')
                .height(20)
                .fontSize(12)
                .margin(10)
            }
            .height('100%')
          }
          .width('100%')
          .justifyContent(FlexAlign.SpaceBetween)
        }
        .height('100%')
        .width(`calc(100% - ${80 + 2 * this.radiusWdthSmall}vp)`)
        .border({
          width: { left: 0, right: this.borderWdth, top: this.borderWdth, bottom: this.borderWdth },
          color: '#f00',
        })
        .borderRadius({
          topRight: this.radiusWdthBig,
          bottomRight: this.radiusWdthBig,
        })
      }
      .width(300)
      .height(80)
      // .backgroundColor('#f00')
      .linearGradient({
        angle: 90,
        colors: [['rgba(255,0,0,0.7)', 0.0], ['rgba(255,0,0,0.3)', 1]]
      })
      .borderRadius(this.radiusWdthBig)
    }.width('100%').margin({ top: 15 })
  }
}
  • 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.
  • 36.
  • 37.
  • 38.
  • 39.
  • 40.
  • 41.
  • 42.
  • 43.
  • 44.
  • 45.
  • 46.
  • 47.
  • 48.
  • 49.
  • 50.
  • 51.
  • 52.
  • 53.
  • 54.
  • 55.
  • 56.
  • 57.
  • 58.
  • 59.
  • 60.
  • 61.
  • 62.
  • 63.
  • 64.
  • 65.
  • 66.
  • 67.
  • 68.
  • 69.
  • 70.
  • 71.
  • 72.
  • 73.
  • 74.
  • 75.
  • 76.
  • 77.
  • 78.
  • 79.
  • 80.
  • 81.
  • 82.
  • 83.
  • 84.
  • 85.
  • 86.
  • 87.
  • 88.
  • 89.
  • 90.
  • 91.
  • 92.
  • 93.
  • 94.
  • 95.
  • 96.
  • 97.
  • 98.
  • 99.
  • 100.
  • 101.
  • 102.
  • 103.
  • 104.
  • 105.
  • 106.
  • 107.
  • 108.
  • 109.
  • 110.
  • 111.
  • 112.
  • 113.
  • 114.
  • 115.
  • 116.
  • 117.
  • 118.
  • 119.
  • 120.
  • 121.
  • 122.
  • 123.
  • 124.
  • 125.
  • 126.
  • 127.
  • 128.
  • 129.
  • 130.
  • 131.
  • 132.
  • 133.
  • 134.
  • 135.
  • 136.
  • 137.
  • 138.
  • 139.
  • 140.
  • 141.
  • 142.
  • 143.
  • 144.
  • 145.
  • 146.
  • 147.
  • 148.
  • 149.
  • 150.
  • 151.
  • 152.
  • 153.
  • 154.
  • 155.
  • 156.
  • 157.
  • 158.
  • 159.
  • 160.
  • 161.
  • 162.
  • 163.
  • 164.
  • 165.
  • 166.
  • 167.
  • 168.
  • 169.
  • 170.
  • 171.
  • 172.
  • 173.
分享
微博
QQ
微信
回复
2024-12-20 18:06:09
相关问题
如何实现一个仪表盘样式组件
1086浏览 • 1回复 待解决
不同组件不同样式效果如何实现
1159浏览 • 1回复 待解决
HarmonyOS 如何实现通用样式
682浏览 • 1回复 待解决
HarmonyOS 如何实现动态样式
508浏览 • 1回复 待解决
HarmonyOS 如何实现剪裁样式
491浏览 • 1回复 待解决
HarmonyOS 如何实现气泡样式
577浏览 • 1回复 待解决
HarmonyOS 如何设定tabs组件tabbar样式
1405浏览 • 1回复 待解决
@Extend样式如何组件共享?
2948浏览 • 1回复 待解决
HarmonyOS swiper组件样式
751浏览 • 1回复 待解决
HarmonyOS如何自定义视频组件样式
1221浏览 • 1回复 待解决
如何设置组件不同状态下样式
2656浏览 • 1回复 待解决
HarmonyOS Text 组件 UI样式
691浏览 • 1回复 待解决