HarmonyOS 鸿蒙Next中Text组件如何设置文字内容的渐变效果?
·
HarmonyOS 鸿蒙Next中Text组件如何设置文字内容的渐变效果?
Text组件,可以通过 .linearGradient 设置背景色的渐变,那么如何设置文字内容的渐变效果呢?
请参考如下demo:
@State message: string = ‘Hello World’;
build() {
Row() {
Column() {
Row() {
Text(this.message)
.fontSize(50)
.fontWeight(FontWeight.Bold)
.blendMode(BlendMode.DST_IN, BlendApplyType.OFFSCREEN)
}.linearGradient({
direction: GradientDirection.Right,
colors: [[0xff0000, 0.0], [0x0000ff, 0.3], [0xffff00, 1.0]]
}).blendMode(BlendMode.SRC_OVER, BlendApplyType.OFFSCREEN)
}
.width(‘100%’)
}
.height(‘100%’)
}
}
更多推荐


所有评论(0)