HarmonyOS 怎么给bindPopup设置全屏的蒙版

怎么给bindPopup设置全屏的蒙版

HarmonyOS
2024-12-20 17:11:35
浏览
收藏 0
回答 1
回答 1
按赞同
/
按时间
superinsect

参考如下demo:

@Entry
@Component
struct PopupExample {
  @State handlePopup: boolean = false
  @State customPopup: boolean = false
  // popup构造器定义弹框内容
  @Builder popupBuilder() {
    Row({ space: 2 }) {
      Image($r("app.media.startIcon")).width(24).height(24).margin({ left: -5 })
      Text('Custom Popup').fontSize(10)
    }.width(100).height(50).padding(5)
  }

  build() {
    Flex({ direction: FlexDirection.Column }) {
      // PopupOptions 类型设置弹框内容
      Button('PopupOptions')
        .onClick(() => {
          this.handlePopup = !this.handlePopup
        })
        .bindPopup(this.handlePopup, {
          builder: this.popupBuilder,
          placement: Placement.Top,
          mask: {color: Color.Gray},
          popupColor: Color.Yellow,
          enableArrow: true,
          message: 'This is a popup with PopupOptions',
          placementOnTop: true,
          showInSubWindow:false,
          primaryButton: {
            value: 'confirm',
            action: () => {
              this.handlePopup = !this.handlePopup
              console.info('confirm Button click')
            }
          },
          // 第二个按钮
          secondaryButton: {
            value: 'cancel',
            action: () => {
              this.handlePopup = !this.handlePopup
              console.info('cancel Button click')
            }
          },
          onStateChange: (e) => {
            console.info(JSON.stringify(e.isVisible))
            if (!e.isVisible) {
              this.handlePopup = false
            }
          }
        })
        .position({ x: 100, y: 150 })

    }.width('100%').padding({ top: 5 })
  }
}
  • 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.
分享
微博
QQ
微信
回复
2024-12-20 18:15:11
相关问题
HarmonyOS bindPopup设置color无效
1845浏览 • 0回复 待解决
HarmonyOS bindPopup如何设置箭头颜色
907浏览 • 1回复 待解决
怎么组件设置下边框?
7603浏览 • 1回复 待解决
TextField怎么某段文字设置颜色
9674浏览 • 2回复 待解决
HarmonyOS bindPopup使用
825浏览 • 1回复 待解决
HarmonyOS page设置全屏问题
851浏览 • 1回复 待解决
如何设置全屏返回动效
2580浏览 • 1回复 待解决
图片设置replaceholderImage方法
704浏览 • 1回复 待解决
HarmonyOS Video组件全屏怎么实现
681浏览 • 1回复 待解决
HarmonyOS 如何span背景设置padding
651浏览 • 1回复 待解决