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) // 设置根组件的颜色饱和度
  }
}
分享
微博
QQ
微信
回复
2025-01-09 18:24:10
相关问题
HarmonyOS 如何实现全局页面
224浏览 • 1回复 待解决
如何实现页面背景颜色
1098浏览 • 1回复 待解决
HarmonyOS 页面处理
232浏览 • 1回复 待解决
APP整体的最佳实践
654浏览 • 1回复 待解决
HarmonyOS有一键功能吗
635浏览 • 1回复 待解决
HarmonyOS 如何一键
417浏览 • 1回复 待解决
HarmonyOS 有没有方法直接退出APP
858浏览 • 1回复 待解决
HarmonyOS loading 跨页面实现方式?
392浏览 • 1回复 待解决
HarmonyOS 动态隐藏页面元素
372浏览 • 1回复 待解决