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