采用colorBlend属性结合Image组件的声明式语法实现。
@Entry @Component struct Page { build() { Column({ space: 20 }) { Row({ space: 20 }) { Text('修改过图标'); Image($r('app.media.startIcon')) .colorBlend(Color.Red) .height(50) .width(50); }; Row({ space: 20 }) { Text('原始的图标'); Image($r('app.media.startIcon')) .height(50) .width(50); }; } .justifyContent(FlexAlign.Center) .height('100%') .width('100%'); } }