W3Cschool
恭喜您成為首批注冊用戶
獲得88經(jīng)驗值獎勵
設(shè)置組件的遮罩文本。
從API Version 7開始支持。后續(xù)版本如有新增內(nèi)容,則采用上角標(biāo)單獨標(biāo)記該內(nèi)容的起始版本。
名稱 | 參數(shù)類型 | 默認(rèn)值 | 描述 |
---|---|---|---|
overlay | value: string, options?: { align?: Alignment, offset?: {x?: number, y?: number} } | { align: Alignment.TopStart, offset: { x: 0, y: 0} } | 在當(dāng)前組件上,增加遮罩文本。 value: 遮罩文本內(nèi)容。 options: 文本定位,align設(shè)置文本相對于組件的方位,offset為文本基于自身左上角的偏移量。文本默認(rèn)處于組件左上角。 兩者都設(shè)置時效果重疊,文本相對于組件方位定位后再基于當(dāng)前位置文本的左上角進(jìn)行偏移。 從API version 9開始,該接口支持在ArkTS卡片中使用。 |
- // xxx.ets
- @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)
- .overlay("Winter is a beautiful season, especially when it snows.", {
- align: Alignment.Bottom,
- offset: { x: 0, y: -15 }
- })
- }.border({ color: Color.Black, width: 2 })
- }.width('100%')
- }.padding({ top: 20 })
- }
- }
Copyright©2021 w3cschool編程獅|閩ICP備15016281號-3|閩公網(wǎng)安備35020302033924號
違法和不良信息舉報電話:173-0602-2364|舉報郵箱:jubao@eeedong.com
掃描二維碼
下載編程獅App
編程獅公眾號
聯(lián)系方式:
更多建議: