• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1# 隐私遮罩
2
3用于对组件内容进行隐私遮罩处理。
4
5>  **说明:**
6>
7> 从API Version 10开始支持。后续版本如有新增内容,则采用上角标单独标记该内容的起始版本。
8
9## obscured
10
11obscured(reasons: Array<ObscuredReasons>)
12
13设置组件内容的遮罩类型。
14
15**系统能力:** SystemCapability.ArkUI.ArkUI.Full
16
17**参数:**
18
19
20| 参数名 | 类型                                     | 必填                                   | 描述                                  |
21| -----| ------------------------------------------ | ------------------------------------ | ------------------------------------ |
22| reasons | Array<[ObscuredReasons](ts-appendix-enums.md#obscuredreasons10)> | 是 | 设置组件内容的遮罩类型。<br>默认值:[]<br/>该接口支持在ArkTS卡片中使用。<br/>仅支持[Image](ts-basic-components-image.md)组件和[Text](ts-basic-components-text.md)组件的隐私遮罩处理。<br/>**说明:**<br/>如需在图片加载过程中显示隐私遮罩,需要设置Image组件的宽度和高度。<br/>Text组件设置子组件时,不支持隐私遮罩。 |
23
24## 示例
25
26```ts
27// xxx.ets
28@Entry
29@Component
30struct ObscuredExample {
31  build() {
32    Row() {
33      Column() {
34        Text('Text not set obscured attribute').fontSize(10).fontColor(Color.Black)
35        Text('This is an example for text obscured attribute.')
36          .fontSize(30)
37          .width('600px')
38          .fontColor(Color.Black)
39          .border({ width: 1 })
40        Text('Image not set obscured attribute').fontSize(10).fontColor(Color.Black)
41        Image($r('app.media.icon'))
42          .width('200px')
43          .height('200px')
44        Text('Text set obscured attribute').fontSize(10).fontColor(Color.Black)
45        Text('This is an example for text obscured attribute.')
46          .fontSize(30)
47          .width('600px')
48          .fontColor(Color.Black)
49          .border({ width: 1 })
50          .obscured([ObscuredReasons.PLACEHOLDER])
51        Text('Image set obscured attribute').fontSize(10).fontColor(Color.Black)
52        Image($r('app.media.icon'))
53          .width('200px')
54          .height('200px')
55          .obscured([ObscuredReasons.PLACEHOLDER])
56      }
57      .width('100%')
58    }
59    .height('100%')
60  }
61}
62```
63
64![obscured](figures/obscured.png)
65
66