鸿蒙开发之组件border属性

@Entry
@Component
struct OfficialBorderPage {

  build() {
    Row() {
      Column() {
        Row() {
          Text('border style')
            //文本border属性设置
            .border({
              width: {
                left:3,
                right:10,
                top:5,
                bottom:1
              },
              radius:{
                bottomLeft:3,
                topRight:15
              },
              style:{
                top:BorderStyle.Dashed,
                right:BorderStyle.Dotted,
                bottom:BorderStyle.Solid
              },
              color:{
                top: Color.Red,
                bottom: Color.Green,
                left: Color.Orange
              }
            })
              //也可以这样设置
              // .borderStyle(BorderStyle.Dashed)
              // .borderColor(Color.Red)
              // .borderRadius({'topLeft':13,'topRight':8,'bottomLeft':5})
              // .borderWidth(3)
            .fontSize(50)
            .fontWeight(FontWeight.Bold)
            .margin({left:20})
        }
        .width('80%')
        .height('50%')
        .backgroundColor(Color.Yellow)
        .borderWidth(10)
        //Row组件的borderImage属性设置图片或渐变边框
        //仅适用于容器组件,如Row、Column、Flex,在非容器组件上使用会失效。
        .borderImage({
          source:{
            angle: 90,
            direction: GradientDirection.Bottom,
            colors: [[0xAEE1E1, 0.0], [0xD3E0DC, 0.3], [0xFCD1D1, 1.0]]
          },
          slice: { top: 10, bottom: 10, left: 10, right: 10 },
          repeat: RepeatMode.Stretch,
          outset:{top:40,left:0,right:20,bottom:10},
          fill: false
        })

      }
      .width('100%')

    }
    .height('100%')
  }
}

  • 10
    点赞
  • 10
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值