颜色资源文件转字符串 鸿蒙
·
资源文件转字符串 鸿蒙
export function intToHexColor(colorInt: number): string {
// 使用位掩码提取RGB部分(去掉Alpha)
const rgb = colorInt & 0xFFFFFF;
// 转换为6位十六进制
return '#' + rgb.toString(16).padStart(6, '0').toUpperCase();
}
export function ResourceToString(resource:Resource):string{
return intToHexColor(getContext().resourceManager.getColorSync(resource))
}
更多推荐

所有评论(0)