ts-universal-attributes-overlay.md 1.2 KB
Newer Older
Z
zengyawen 已提交
1
# Overlay
Z
zengyawen 已提交
2 3


E
esterzhou 已提交
4
> ![icon-note.gif](public_sys-resources/icon-note.gif) **NOTE**
Z
zengyawen 已提交
5 6 7 8
> This attribute is supported since API version 7. Updates will be marked with a superscript to indicate their earliest API version.


## Required Permissions
Z
zengyawen 已提交
9 10 11

None

Z
zengyawen 已提交
12

Z
zengyawen 已提交
13 14 15
## Attributes


E
esterzhou 已提交
16
| Name | Type | Default Value | Description |
Z
zengyawen 已提交
17
| -------- | -------- | -------- | -------- |
E
esterzhou 已提交
18
| overlay | title: string,<br/>options: {<br/>align?: [Alignment](ts-appendix-enums.md#alignment-enums),<br/>offset?: {x: number, y: number}<br/>} | {<br/>align: Alignment.Center,<br/>offset: {0, 0}<br/>} | Mask added to the component. The mask has the same layout as the component. |
Z
zengyawen 已提交
19 20 21


## Example
Z
zengyawen 已提交
22 23 24 25 26 27 28 29 30 31 32 33 34 35


```
@Entry
@Component
struct OverlayExample {
  build() {
    Column() {
      Column() {
        Text('floating layer')
          .fontSize(12).fontColor(0xCCCCCC).maxLines(1)
        Column() {
          Image($r('app.media.img'))
            .width(240).height(240)
Z
zengyawen 已提交
36
            .overlay("Winter is a beautiful season, especially when it snows.", { align: Alignment.Bottom, offset: { x: 0, y: -15 } })
Z
zengyawen 已提交
37 38 39 40 41 42 43
        }.border({ color: Color.Black, width: 2 })
      }.width('100%')
    }.padding({ top: 20 })
  }
}
```

Z
zengyawen 已提交
44
![en-us_image_0000001212058472](figures/en-us_image_0000001212058472.png)