HarmonyOS bindPopup使用,如何设置箭头颜色和气泡内容圆角

HarmonyOS
2024-12-18 17:11:23
浏览
收藏 0
回答 1
回答 1
按赞同
/
按时间
put_get

radius:‘10vp’// 设置气泡的圆角

backgroundBlurStyle: BlurStyle.NONE, //设置箭头颜色,

其与popupColor属性关联Demo 参考如下

@Entry
@Component
struct BindPopupDemo {
  // 第一步:定义变量控制弹窗显示
  @State customPopup: boolean = false;

  // 第二步:popup构造器定义弹框内容
  @Builder
  popupBuilder() {
    Column({ space: 2 }) {
      Row().width(64)
        .height(64)
        .backgroundColor(0x409eff)
      Text('Popup')
        .fontSize(10)
        .fontColor(Color.White)
    }
    .justifyContent(FlexAlign.SpaceAround)
    .width(100)
    .height(100)
    .padding(5)
  }

  @Builder
  customBubbleInstructionBuilder() {
    Stack() {
      Text() {
        Span("2021年12月20日-2022月1日30日每人限购8件  已购买3件,还可购5件").fontSize(12)
        Span(" 已购买3件,还可购5件").fontSize(14)
      }.fontColor(Color.White)
      .maxLines(2).textOverflow({ overflow: TextOverflow.Ellipsis }).ellipsisMode(EllipsisMode.END)
    }.backgroundColor(0x409eff)
    .width(100)
    .padding({
      left: 12,
      right: 12,
      top: 18,
      bottom: 8
    })
  }

  build() {
    Column() {

      Button('click')// 第四步:创建点击事件,控制弹窗显隐
        .onClick(() => {
          this.customPopup = !this.customPopup;
        })
        .backgroundColor(0xf56c6c)// 第三步:使用bindPopup接口将弹窗内容绑定给元素
        .bindPopup(this.customPopup, {
          builder: this.customBubbleInstructionBuilder,
          placement: Placement.Top,
          maskColor: 0x33000000,
          popupColor: 0xf56c6c,
          enableArrow: true,
          radius: '10vp', // 设置气泡的圆角
          backgroundBlurStyle: BlurStyle.NONE,
          onStateChange: (e) => {
            if (!e.isVisible) {
              this.customPopup = false;
            }
          }
        })
    }
    .justifyContent(FlexAlign.Center)
    .width('100%')
    .height(437)
  }
}
  • 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.
分享
微博
QQ
微信
回复
2024-12-18 18:44:44
相关问题
HarmonyOS bindPopup如何设置箭头颜色
910浏览 • 1回复 待解决
HarmonyOS bindPopup如何去掉圆角
763浏览 • 1回复 待解决
HarmonyOS bindPopup自定义气泡问题
516浏览 • 1回复 待解决
HarmonyOS 气泡背景颜色问题
517浏览 • 1回复 待解决
HarmonyOS bindPopup设置color无效
1860浏览 • 0回复 待解决
HarmonyOS Canvas如何设置圆角
735浏览 • 1回复 待解决
HarmonyOS bindPopup使用
825浏览 • 1回复 待解决
HarmonyOS span中如何设置圆角
1106浏览 • 1回复 待解决
HarmonyOS 镜像语言下箭头怎么设置
705浏览 • 1回复 待解决
popup组件气泡框指向颜色怎么修改?
7993浏览 • 1回复 待解决
HarmonyOS 组件.bindPopup属性使用问题
1063浏览 • 1回复 待解决
HarmonyOS CustomDialog怎么设置圆角
980浏览 • 1回复 待解决