国产精品久久久aaaa,日日干夜夜操天天插,亚洲乱熟女香蕉一区二区三区少妇,99精品国产高清一区二区三区,国产成人精品一区二区色戒,久久久国产精品成人免费,亚洲精品毛片久久久久,99久久婷婷国产综合精品电影,国产一区二区三区任你鲁

0
  • 聊天消息
  • 系統消息
  • 評論與回復
登錄后你可以
  • 下載海量資料
  • 學習在線課程
  • 觀看技術視頻
  • 寫文章/發帖/加入社區
會員中心
創作中心

完善資料讓更多小伙伴認識你,還能領取20積分哦,立即完善>

3天內不再提示

ArkUI如何自定義彈窗(eTS)

ArkUI詳解 ? 來源:鴻蒙實驗室 ? 作者:鴻蒙實驗室 ? 2022-08-31 08:24 ? 次閱讀
加入交流群
微信小助手二維碼

掃碼添加小助手

加入工程師交流群

自定義彈窗其實也是比較簡單的,通過CustomDialogController類就可以顯示自定義彈窗。

接下來我們通過代碼來看一下

大家也都用過@Entry,@Component等彈窗的話,只要用@CustomDialog就可以

先來預覽一下我實現的效果:

gif145gif

import

CustomDialogExample

from

'./customdialog'

?

@

Entry

@

Component

struct

Index

{

?

// 方式一:使用箭頭函數

onAccept

=

()

=>

{

console

.

info

(

'確定'

)

this

.

dialogController

.

close

();

}

dialogController

:

CustomDialogController

=

new

CustomDialogController

({

builder

:

CustomDialogExample

({

cancel

:

this

.

onCancel

,

confirm

:

this

.

onAccept

}),

?

alignment

:

DialogAlignment

.

Center

,

cancel

: ()

=>

{

console

.

log

(

"cancel"

)

// 點擊蒙層的回調

},

autoCancel

:

true

,

// 允許點擊蒙層關閉彈窗

customStyle

:

false

// 使用自定義樣式

})

?

onCancel

() {

console

.

info

(

'取消'

)

}

?

build

() {

Column

({}) {

Button

(

' 自定義彈窗'

)

.

onClick

(()

=>

{

//打開彈窗

this

.

dialogController

.

open

();

})

?

?

}.

width

(

"100%"

).

height

(

"100%"

).

alignItems

(

HorizontalAlign

.

Center

).

justifyContent

(

FlexAlign

.

Center

)

}

}

/*

* Copyright (c) 2021 JianGuo Device Co., Ltd.

* Licensed under the Apache License, Version 2.0 (the "License");

* you may not use this file except in compliance with the License.

* You may obtain a copy of the License at

*

* http://www.apache.org/licenses/LICENSE-2.0

*

* Unless required by applicable law or agreed to in writing, software

* distributed under the License is distributed on an "AS IS" BASIS,

* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.

* See the License for the specific language governing permissions and

* limitations under the License.

*/

?

//通過CustomDialogController類顯示自定義彈窗。

@

CustomDialog

struct

CustomDialogExample

{

controller

:

CustomDialogController

cancel

: ()

=>

void

confirm

: ()

=>

void

?

build

() {

?

?

Flex

({

justifyContent

:

FlexAlign

.

Center

,

alignItems

:

ItemAlign

.

Center

,

alignContent

:

FlexAlign

.

Center

}) {

Button

(

'取消'

).

fontSize

(

36

)

.

onClick

(()

=>

{

//方式二:關閉彈窗

this

.

controller

.

close

()

this

.

cancel

()

}).

backgroundColor

(

0xffffff

).

fontColor

(

Color

.

Black

)

Button

(

'確定'

).

fontSize

(

36

)

.

onClick

(()

=>

{

// this.controller.close()

this

.

confirm

()

}).

backgroundColor

(

0xffffff

).

fontColor

(

Color

.

Red

)

}.

margin

({

bottom

:

10

}).

width

(

"100%"

).

height

(

200

)

}

?

}

export

default

CustomDialogExample

上面就是一個簡單的自定義彈窗

接下來看一下它的有關屬性

CustomDialogController 定義了 open()close() 方法,它們說明如下:

open:打開對話框,如果對話框已經打開,則再次打開無效。

close:關閉對話框,如果對話框已經關閉,則再次關閉無效。

value:創建控制器需要的配置參數,

  • CustomDialogControllerOptions

說明如下:

builder:創建自定義彈窗的構造器。

cancel:點擊蒙層的事件回調。

autoCancel:是否允許點擊遮障層退出。

alignment:彈窗在豎直方向上的對齊方式。

offset:彈窗相對 alignment 所在位置的偏移量。

customStyle:彈窗容器樣式是否自定義。

源碼

declare interface CustomDialogControllerOptions {

/**

* Custom builder function.

* @since 7

*/

builder: any;

?

/**

* Defines the cancel function.

* @since 7

*/

cancel?: () => void;

?

/**

* Defines if use auto cancel when click on the outside of the dialog.

* @since 7

*/

autoCancel?: boolean;

?

/**

* Defines the dialog alignment of the screen.

* @since 7

*/

alignment?: DialogAlignment;

?

/**

* Defines the dialog offset.

* @since 7

*/

offset?: Offset;

?

/**

* Defines if use costom style.

* @since 7

*/

customStyle?: boolean;

?

/**

* Grid count of dialog.

* @since 8

*/

gridCount?: number;

}

DialogAlignment的位置

名稱 描述
Top 垂直頂部對齊。
Center 垂直居中對齊。
Bottom 垂直底部對齊。
Default 默認對齊。
TopStart8+ 左上對齊。
TopEnd8+ 右上對齊。
CenterStart8+ 左中對齊。
CenterEnd8+ 右中對齊。
BottomStart8+ 左下對齊。
BottomEnd8+ 右下對齊。

參考文檔

自定義彈窗

語法糖

審核編輯:湯梓紅
聲明:本文內容及配圖由入駐作者撰寫或者入駐合作網站授權轉載。文章觀點僅代表作者本人,不代表電子發燒友網立場。文章及其配圖僅供工程師學習之用,如有內容侵權或者其他違規問題,請聯系本站處理。 舉報投訴
  • Component
    +關注

    關注

    0

    文章

    13

    瀏覽量

    9160
  • OpenHarmony
    +關注

    關注

    33

    文章

    3950

    瀏覽量

    21017
收藏 人收藏
加入交流群
微信小助手二維碼

掃碼添加小助手

加入工程師交流群

    評論

    相關推薦
    熱點推薦

    基于ArkUI eTS開發的堅果食譜(NutRecipes)

    基于ArkUI eTS開發的堅果食譜(NutRecipes)
    的頭像 發表于 08-18 08:23 ?2419次閱讀
    基于<b class='flag-5'>ArkUI</b> <b class='flag-5'>eTS</b>開發的堅果食譜(NutRecipes)

    HarmonyOS開發實例:【自定義Emitter】

    使用[Emitter]實現事件的訂閱和發布,使用[自定義彈窗]設置廣告信息。
    的頭像 發表于 04-14 11:37 ?1827次閱讀
    HarmonyOS開發實例:【<b class='flag-5'>自定義</b>Emitter】

    HarmonyOS開發案例:【彈窗使用】

    基于dialog和button組件,實現彈窗的幾種自定義效果
    的頭像 發表于 04-25 17:44 ?2585次閱讀
    HarmonyOS開發案例:【<b class='flag-5'>彈窗</b>使用】

    HarmonyOS開發案例:【 自定義彈窗

    基于ArkTS的聲明式開發范式實現了三種不同的彈窗,第一種直接使用公共組件,后兩種使用CustomDialogController實現自定義彈窗
    的頭像 發表于 05-16 18:18 ?2483次閱讀
    HarmonyOS開發案例:【 <b class='flag-5'>自定義</b><b class='flag-5'>彈窗</b>】

    HarmonyOS應用自定義鍵盤解決方案

    自定義鍵盤是一種替換系統默認鍵盤的解決方案,可實現鍵盤個性化交互。允許用戶結合業務需求與操作習慣,對按鍵布局進行可視化重構、設置多功能組合鍵位,使輸入更加便捷和舒適。在安全防護層面,自定義鍵盤可以
    的頭像 發表于 06-05 14:19 ?2298次閱讀

    OpenHarmony應用開發之自定義彈窗

    本文轉載自《OpenHarmony應用開發之自定義彈窗》,作者:zhushangyuan_ ? 應用場景 在應用的使用和開發中,彈窗是一個很常見的場景,自定義
    發表于 09-06 14:40

    1602自定義字符

    1602液晶能夠顯示自定義字符,能夠根據讀者的具體情況顯示自定義字符。
    發表于 01-20 15:43 ?1次下載

    三種自定義彈窗UI組件封裝的實現

    鴻蒙已經提供了全局 UI 方法自定義彈窗,本文是基于基礎的自定義彈窗來實現提示消息彈窗、確認彈窗
    的頭像 發表于 03-30 09:28 ?4513次閱讀

    自定義視圖組件教程案例

    自定義組件 1.自定義組件-particles(粒子效果) 2.自定義組件- pulse(脈沖button效果) 3.自定義組件-progress(progress效果) 4.
    發表于 04-08 10:48 ?15次下載

    labview自定義控件

    labview自定義精美控件
    發表于 05-15 16:46 ?22次下載

    在OpenHarmony上如何使用不同的彈窗

    應用中經常用到彈窗,比如警告彈窗、日期選擇彈窗、文本選擇彈窗以及其他自定義彈窗等等。
    的頭像 發表于 06-18 15:10 ?2117次閱讀
    在OpenHarmony上如何使用不同的<b class='flag-5'>彈窗</b>

    自定義算子開發

    一個完整的自定義算子應用過程包括注冊算子、算子實現、含自定義算子模型轉換和運行含自定義op模型四個階段。在大多數情況下,您的模型應該可以通過使用hb_mapper工具完成轉換并順利部署到地平線芯片上……
    的頭像 發表于 04-07 16:11 ?5264次閱讀
    <b class='flag-5'>自定義</b>算子開發

    labview超快自定義控件制作和普通自定義控件制作

    labview超快自定義控件制作和普通自定義控件制作
    發表于 08-21 10:32 ?14次下載

    鴻蒙ArkUI開發-應用添加彈窗

    彈窗是一種模態窗口,通常用來展示用戶當前需要的或用戶必須關注的信息或操作。在彈出框消失之前,用戶無法操作其他界面內容。ArkUI為我們提供了豐富的彈窗功能
    的頭像 發表于 01-24 17:22 ?1835次閱讀
    鴻蒙<b class='flag-5'>ArkUI</b>開發-應用添加<b class='flag-5'>彈窗</b>

    鴻蒙ArkUI實例:【自定義組件】

    組件是 OpenHarmony 頁面最小顯示單元,一個頁面可由多個組件組合而成,也可只由一個組件組合而成,這些組件可以是ArkUI開發框架自帶系統組件,比如?`Text`?、?`Button`?等,也可以是自定義組件,本節筆者簡單介紹一下
    的頭像 發表于 04-08 10:17 ?1590次閱讀