HarmonyOS 有没有方式实现将整个页面置灰,包含页面内所有元素

HarmonyOS
2025-01-09 16:47:35
浏览
收藏 0
回答 1
回答 1
按赞同
/
按时间
fox280

示例参考如下:

@Entry
@Component
struct Index {
  @State saturateValue: number = 0;

  build() {
    Column({ space: 10 }) {
      Row({ space: 10 }) {
        Text('Red Text')
          .fontColor(Color.Red)
          .fontSize(22)
        Text('Blue Text')
          .fontColor(Color.Blue)
          .fontSize(22)
      }

      Row({ space: 10 }) {
        Button('White Text')
          .fontColor(Color.White)
      }

      Flex()
        .width("100%")
        .height(50)
        .backgroundColor(Color.Pink)
      Image($r("app.media.startIcon"))
        .height(150)

      Row({ space: 10 }) {
        Button('页面置灰')
          .onClick(() => {
            this.saturateValue = 1; // 页面置灰
          })
        Button('恢复彩色')
          .onClick(() => {
            this.saturateValue = 0; // 页面复原
          })
      }
    }
    .width("100%")
    .height("100%")
    .padding(10)
    .grayscale(this.saturateValue) // 设置根组件的颜色饱和度
  }
}
  • 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.
分享
微博
QQ
微信
回复
2025-01-09 18:24:10


相关问题
HarmonyOS 如何实现全局页面
518浏览 • 1回复 待解决
HarmonyOS 页面处理
600浏览 • 1回复 待解决
如何实现页面背景颜色
1403浏览 • 1回复 待解决
APP整体的最佳实践
1101浏览 • 1回复 待解决
HarmonyOS有一键功能吗
975浏览 • 1回复 待解决
HarmonyOS 如何一键
877浏览 • 1回复 待解决
HarmonyOS 有没有方法直接退出APP
1210浏览 • 1回复 待解决
HarmonyOS loading 跨页面实现方式?
745浏览 • 1回复 待解决
HarmonyOS 动态隐藏页面元素
824浏览 • 1回复 待解决