Przeglądaj źródła

自定义背景 顶部透明bug解决

onecold 1 rok temu
rodzic
commit
8f91b01470

+ 9 - 8
entry/src/main/ets/view/LocalMusic.ets

@@ -322,7 +322,7 @@ export struct LocalMusic {
     .setTitleFontColor(Color.White)
     .setTitleBarBackground($r('app.color.title_bar_bg'))
     .setTitleBarBottomLineColor($r('app.color.title_bar_bg'))
-    .setRightTitleBackground($r('app.color.title_bar_bg'))
+    .setLeftTitleStateNormalStyleColor($r('app.color.title_bar_bg'))
     .setRightIcon($r('app.media.add'))
     .setOnRightClickListener(() => {
       this.showSheelDialog()
@@ -367,15 +367,15 @@ export struct LocalMusic {
     this.isCustomizeBg  = PreferencesUtil.getBooleanSync(SettingPage.IS_CUSTOMIZE_BG, false)
     this.customizeBgPath  = PreferencesUtil.getStringSync(SettingPage.IS_CUSTOMIZE_BG_PATH, '')
     if(this.isCustomizeBg){
-      this.titleBarModel.setRightTitleBackground(Color.Transparent)
+      this.titleBarModel.setRightTitleStateNormalStyleColor(Color.Transparent)
       this.titleBarModel.setTitleBarBackground(Color.Transparent)
       this.titleBarModel.setTitleBarBottomLineColor(Color.Transparent)
-      this.titleBarModel.setLeftTitleBackground(Color.Transparent)
+      this.titleBarModel.setLeftTitleStateNormalStyleColor(Color.Transparent)
 
     }else{
       this.titleBarModel.setTitleBarBackground($r('app.color.title_bar_bg'))
       this.titleBarModel.setTitleBarBottomLineColor($r('app.color.title_bar_bg'))
-      this.titleBarModel  .setRightTitleBackground($r('app.color.title_bar_bg'))
+      // this.titleBarModel  .setRightTitleBackground($r('app.color.title_bar_bg'))
     }
 
     Utility.getAppName(getContext(this)).then((appName: string) => {
@@ -460,14 +460,15 @@ export struct LocalMusic {
     this.isCustomizeBg  = PreferencesUtil.getBooleanSync(SettingPage.IS_CUSTOMIZE_BG, false)
     this.customizeBgPath  = PreferencesUtil.getStringSync(SettingPage.IS_CUSTOMIZE_BG_PATH, '')
     if(this.isCustomizeBg){
+      this.titleBarModel.setRightTitleStateNormalStyleColor(Color.Transparent)
       this.titleBarModel.setTitleBarBackground(Color.Transparent)
       this.titleBarModel.setTitleBarBottomLineColor(Color.Transparent)
-      this.titleBarModel.setRightTitleBackground(Color.Transparent)
-      this.titleBarModel.setLeftTitleBackground(Color.Transparent)
+      this.titleBarModel.setLeftTitleStateNormalStyleColor(Color.Transparent)
     }else{
       this.titleBarModel.setTitleBarBackground($r('app.color.title_bar_bg'))
-        .setTitleBarBottomLineColor($r('app.color.title_bar_bg'))
-        .setRightTitleBackground($r('app.color.title_bar_bg'))
+      this.titleBarModel .setTitleBarBottomLineColor($r('app.color.title_bar_bg'))
+      this.titleBarModel.setRightTitleStateNormalStyleColor($r('app.color.title_bar_bg'))
+      this.titleBarModel.setLeftTitleStateNormalStyleColor($r('app.color.title_bar_bg'))
     }
 
     this.doUpdateData()

+ 1 - 1
entry/src/main/ets/view/TitleBar.ets

@@ -255,10 +255,10 @@ export struct TitleBar {
       // 右边布局
       if (this.customRightView) {
         this.customRightView()
-          .backgroundColor($r('app.color.title_bar_bg'))
       } else {
         if (this.model.showRightSideLayout) {
           this.normalBothSidesLayout(TitleBar.BothSidesLayoutType.RIGHT)
+
         } else {
           this.blankLayout()
         }