#鸿蒙学习大百科#页面如何实现自定义主题风格?

页面如何实现自定义主题风格?

HarmonyOS
2024-09-20 10:48:48
浏览
已于2024-9-20 12:22:20修改
收藏 0
回答 1
待解决
回答 1
按赞同
/
按时间
风间爱小新V

import { CustomColors, CustomTheme, Theme } from '@kit.ArkUI'   
class AppColors implements CustomColors { 
fontPrimary: ResourceColor = $r('app.color.brand_purple')
 
backgroundEmphasize: ResourceColor = $r('app.color.brand_purple') 
}
class AppColorsSec implements CustomColors { 
fontPrimary: ResourceColor = $r('app.color.brand') 
backgroundEmphasize: ResourceColor = $r('app.color.brand')  
}class AppTheme implements CustomTheme { 
public colors: AppColors = new AppColors()} 
class AppThemeSec implements CustomTheme { 
public colors: AppColors = new AppColorsSec()  }

在页面中调用

@State customTheme: CustomTheme = new AppTheme()WithTheme({ theme: this.customTheme })
分享
微博
QQ
微信
回复
2024-09-20 15:59:42
相关问题
#鸿蒙学习大百科#如何实现ui优化?
136浏览 • 1回复 待解决