通过给组件设置renderGroup(true)或者blendMode(BlendMode.SRC_OVER, BlendApplyType.OFFSCREEN)来实现。
可以参考如下示例:
@Entry
@Component
struct Index {
build() {
Row() {
Column() {
Text('你好')
.width(200)
.height(100)
.fontColor(Color.White)
.backgroundColor(Color.Blue)
.fontSize(20)
.textAlign(TextAlign.Center)
.opacity(0.3)
.margin(20)
Text('你好')
.width(200)
.height(100)
.fontColor(Color.White)
.backgroundColor(Color.Blue)
.fontSize(20)
.textAlign(TextAlign.Center)
.opacity(0.3)
.renderGroup(true)
}
.width('100%')
}
.height('100%')
}
}