半模态转场如何控制固定高度

半模态转场如何控制固定高度

HarmonyOS
2024-01-21 12:39:29
浏览
收藏 0
回答 1
回答 1
按赞同
/
按时间
maxdl

可以通过bindSheet的options?: SheetOptions参数对高度进行控制,暂不支持控制固定宽度。

代码示例

@Entry 
@Component 
struct SheetTransitionExample { 
  @State isShow: boolean = false; 
  @State sheetHeight: number = 300; 
 
  @Builder 
  myBuilder() { 
    Column() { 
      Button('change height') 
        .margin(10) 
        .fontSize(20) 
        .onClick(() => { 
          this.sheetHeight = 500; 
        }) 
 
      Button('Set Illegal height') 
        .margin(10) 
        .fontSize(20) 
        .onClick(() => { 
          this.sheetHeight = 0; 
        }) 
    } 
    .width('100%') 
    .height('100%') 
  } 
 
  build() { 
    Column() { 
      Button('transition modal 1') 
        .onClick(() => { 
          this.isShow = true; 
        }) 
        .fontSize(20) 
        .margin(10) 
        .bindSheet(this.isShow, this.myBuilder(), { height: this.sheetHeight, backgroundColor: Color.Green }) 
    } 
    .justifyContent(FlexAlign.Center) 
    .width('100%') 
    .height('100%') 
  } 
}
  • 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.

参考链接

半模态转场

分享
微博
QQ
微信
回复
2024-01-22 15:00:08
相关问题
如何固定模态转场高度
1233浏览 • 1回复 待解决
HarmonyOS 模态转场
755浏览 • 1回复 待解决
HarmonyOS 模态转场如何透传手势?
1045浏览 • 1回复 待解决
HarmonyOS 关于模态转场的疑问
695浏览 • 1回复 待解决
模态转场来实现弹框样式的页面
1496浏览 • 1回复 待解决
HarmonyOS 如何转换模态
711浏览 • 1回复 待解决