鸿蒙Next气泡提示(Popup)的使用
2025-06-27 22:43:16
105次阅读
0个评论
本文介绍自定义的气泡CustomPopupOptions的使用,设置弹出框内容,弹出框位置,是否为模态窗口,默认小箭头的设置,简单动画,看效果:
@Entry
@ComponentV2
struct test{
@Local customPopup: boolean = false
@Builder
viewToolView(){
Row({space:5}){
Image($r("app.media.icon_send")).width(15).height(15)
Text('转发').fontColor(Color.White).fontSize(16)
Image($r("app.media.icon_good")).width(15).height(15)
Text('点赞').fontColor(Color.White).fontSize(16)
Image($r("app.media.icon_comment")).width(15).height(15)
Text('评论').fontColor(Color.White).fontSize(16)
}.padding(5).alignItems(VerticalAlign.Center).justifyContent(FlexAlign.Start)
// .backgroundColor('#5C5C5C')
}
build() {
Column({space:20}){
Text('系统')
Text('TOP').fontSize(20).fontColor(Color.Black).onClick(()=>{
this.customPopup = !this.customPopup
}).bindPopup(this.customPopup, {
builder: this.viewToolView, // 气泡的内容
placement:Placement.Top, // 气泡的弹出位置
backgroundBlurStyle:BlurStyle.NONE,//去除模糊背景
popupColor:'#5C5C5C',
arrowHeight:0, //设置箭头高度
arrowWidth:0,
enableArrow:false, //去掉默认的小箭头
radius:5,
onStateChange: (e) => {
if (!e.isVisible) {
this.customPopup = false
}
}
})
Row(){
Text('RightBottom').fontSize(20).fontColor(Color.Black).onClick(()=>{
this.customPopup = !this.customPopup
}).bindPopup(this.customPopup, {
builder: this.viewToolView, // 气泡的内容
placement:Placement.RightBottom, // 气泡的弹出位置
backgroundBlurStyle:BlurStyle.NONE,//去除模糊背景
popupColor:'#5C5C5C',
arrowHeight:8, //设置箭头高度
arrowWidth:18,
targetSpace:10, //设置popup与目标的间隙
radius:5,
onStateChange: (e) => {
if (!e.isVisible) {
this.customPopup = false
}
}
})
}.width('100%')
Text('Bottom').fontSize(20).fontColor(Color.Black).onClick(()=>{
this.customPopup = !this.customPopup
}).bindPopup(this.customPopup, {
builder: this.viewToolView, // 气泡的内容
placement:Placement.Bottom, // 气泡的弹出位置
mask:false, //是否有遮罩层及遮罩颜色
backgroundBlurStyle:BlurStyle.NONE,//去除模糊背景
popupColor:'#5C5C5C',
enableArrow:true, //是否显示掉默认小箭头
radius:5,
onStateChange: (e) => {
if (!e.isVisible) {
this.customPopup = false
}
}
})
Text('气泡尖角相对于父组件显示位置').fontSize(20).fontColor(Color.Black).onClick(()=>{
this.customPopup = !this.customPopup
}).margin({top:30}).bindPopup(this.customPopup, {
builder: this.viewToolView, // 气泡的内容
placement:Placement.Bottom, // 气泡的弹出位置
mask:false, //是否有遮罩层及遮罩颜色
backgroundBlurStyle:BlurStyle.NONE,//去除模糊背景
popupColor:'#5C5C5C',
enableArrow:true, //是否显示掉默认小箭头
// 气泡尖角相对于父组件显示位置
arrowPointPosition:ArrowPointPosition.START,
radius:5,
onStateChange: (e) => {
if (!e.isVisible) {
this.customPopup = false
}
},
// 设置弹窗显示动效与退出动效 平移+透明度
transition:TransitionEffect.translate({ x: 0, y: 10 }).combine(TransitionEffect.opacity(0)).animation({ duration: 500, curve: Curve.Ease })
})
}.width('100%').height('100%').alignItems(HorizontalAlign.Center).justifyContent(FlexAlign.Center)
}
}
00
- 0回答
- 0粉丝
- 0关注
相关话题
- 鸿蒙开发:实现Popup气泡提示
- 鸿蒙开发:实现popup弹窗
- 鸿蒙Next进度条组件Progress的使用
- 37.[HarmonyOS NEXT Row案例五] 构建智能聊天气泡:Row组件的reverse属性妙用
- 鸿蒙Next MVVM模式使用
- 鸿蒙Next网络请求HTTP和RCP的使用和对比
- 鸿蒙Next并发线程TaskPool使用
- 鸿蒙WebSocket的使用竟如此简单
- Uniapp在鸿蒙中的使用 二
- 鸿蒙Next画布Canvas基础使用演示
- 鸿蒙Next地图服务Map在露天矿山中的使用分享
- 使用DevEcoStudio 开发、编译鸿蒙 NEXT_APP 以及使用中文插件
- 49.[HarmonyOS NEXT RelativeContainer案例六] 智能屏障布局:打造自适应聊天气泡界面
- 鸿蒙Next轮播组件Swiper使用了解
- 鸿蒙Next层叠布局使用Stack还是RelativeContainer?