女人自慰AV免费观看内涵网,日韩国产剧情在线观看网址,神马电影网特片网,最新一级电影欧美,在线观看亚洲欧美日韩,黄色视频在线播放免费观看,ABO涨奶期羡澄,第一导航fulione,美女主播操b

0
  • 聊天消息
  • 系統(tǒng)消息
  • 評(píng)論與回復(fù)
登錄后你可以
  • 下載海量資料
  • 學(xué)習(xí)在線(xiàn)課程
  • 觀看技術(shù)視頻
  • 寫(xiě)文章/發(fā)帖/加入社區(qū)
會(huì)員中心
創(chuàng)作中心

完善資料讓更多小伙伴認(rèn)識(shí)你,還能領(lǐng)取20積分哦,立即完善>

3天內(nèi)不再提示

ArkUI如何自定義彈窗(eTS)

ArkUI詳解 ? 來(lái)源:鴻蒙實(shí)驗(yàn)室 ? 作者:鴻蒙實(shí)驗(yàn)室 ? 2022-08-31 08:24 ? 次閱讀

自定義彈窗其實(shí)也是比較簡(jiǎn)單的,通過(guò)CustomDialogController類(lèi)就可以顯示自定義彈窗。

接下來(lái)我們通過(guò)代碼來(lái)看一下

大家也都用過(guò)@Entry,@Component等彈窗的話(huà),只要用@CustomDialog就可以

先來(lái)預(yù)覽一下我實(shí)現(xiàn)的效果:

gif145gif

import

CustomDialogExample

from

'./customdialog'

?

@

Entry

@

Component

struct

Index

{

?

// 方式一:使用箭頭函數(shù)

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"

)

// 點(diǎn)擊蒙層的回調(diào)

},

autoCancel

:

true

,

// 允許點(diǎn)擊蒙層關(guān)閉彈窗

customStyle

:

false

// 使用自定義樣式

})

?

onCancel

() {

console

.

info

(

'取消'

)

}

?

build

() {

Column

({}) {

Button

(

' 自定義彈窗'

)

.

onClick

(()

=>

{

//打開(kāi)彈窗

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.

*/

?

//通過(guò)CustomDialogController類(lèi)顯示自定義彈窗。

@

CustomDialog

struct

CustomDialogExample

{

controller

:

CustomDialogController

cancel

: ()

=>

void

confirm

: ()

=>

void

?

build

() {

?

?

Flex

({

justifyContent

:

FlexAlign

.

Center

,

alignItems

:

ItemAlign

.

Center

,

alignContent

:

FlexAlign

.

Center

}) {

Button

(

'取消'

).

fontSize

(

36

)

.

onClick

(()

=>

{

//方式二:關(guān)閉彈窗

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

上面就是一個(gè)簡(jiǎn)單的自定義彈窗

接下來(lái)看一下它的有關(guān)屬性

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

open:打開(kāi)對(duì)話(huà)框,如果對(duì)話(huà)框已經(jīng)打開(kāi),則再次打開(kāi)無(wú)效。

close:關(guān)閉對(duì)話(huà)框,如果對(duì)話(huà)框已經(jīng)關(guān)閉,則再次關(guān)閉無(wú)效。

value:創(chuàng)建控制器需要的配置參數(shù),

  • CustomDialogControllerOptions

說(shuō)明如下:

builder:創(chuàng)建自定義彈窗的構(gòu)造器。

cancel:點(diǎn)擊蒙層的事件回調(diào)。

autoCancel:是否允許點(diǎn)擊遮障層退出。

alignment:彈窗在豎直方向上的對(duì)齊方式。

offset:彈窗相對(duì) 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的位置

名稱(chēng) 描述
Top 垂直頂部對(duì)齊。
Center 垂直居中對(duì)齊。
Bottom 垂直底部對(duì)齊。
Default 默認(rèn)對(duì)齊。
TopStart8+ 左上對(duì)齊。
TopEnd8+ 右上對(duì)齊。
CenterStart8+ 左中對(duì)齊。
CenterEnd8+ 右中對(duì)齊。
BottomStart8+ 左下對(duì)齊。
BottomEnd8+ 右下對(duì)齊。

參考文檔

自定義彈窗

語(yǔ)法糖

審核編輯:湯梓紅
聲明:本文內(nèi)容及配圖由入駐作者撰寫(xiě)或者入駐合作網(wǎng)站授權(quán)轉(zhuǎn)載。文章觀點(diǎn)僅代表作者本人,不代表電子發(fā)燒友網(wǎng)立場(chǎng)。文章及其配圖僅供工程師學(xué)習(xí)之用,如有內(nèi)容侵權(quán)或者其他違規(guī)問(wèn)題,請(qǐng)聯(lián)系本站處理。 舉報(bào)投訴
  • Component
    +關(guān)注

    關(guān)注

    0

    文章

    13

    瀏覽量

    8974
  • OpenHarmony
    +關(guān)注

    關(guān)注

    26

    文章

    3824

    瀏覽量

    18144
收藏 人收藏

    評(píng)論

    相關(guān)推薦
    熱點(diǎn)推薦

    基于ArkUI eTS開(kāi)發(fā)的堅(jiān)果食譜(NutRecipes)

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

    HarmonyOS開(kāi)發(fā)實(shí)例:【自定義Emitter】

    使用[Emitter]實(shí)現(xiàn)事件的訂閱和發(fā)布,使用[自定義彈窗]設(shè)置廣告信息。
    的頭像 發(fā)表于 04-14 11:37 ?1241次閱讀
    HarmonyOS開(kāi)發(fā)實(shí)例:【<b class='flag-5'>自定義</b>Emitter】

    HarmonyOS開(kāi)發(fā)案例:【彈窗使用】

    基于dialog和button組件,實(shí)現(xiàn)彈窗的幾種自定義效果
    的頭像 發(fā)表于 04-25 17:44 ?1840次閱讀
    HarmonyOS開(kāi)發(fā)案例:【<b class='flag-5'>彈窗</b>使用】

    HarmonyOS開(kāi)發(fā)案例:【 自定義彈窗

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

    OpenHarmony應(yīng)用開(kāi)發(fā)之自定義彈窗

    本文轉(zhuǎn)載自《OpenHarmony應(yīng)用開(kāi)發(fā)之自定義彈窗》,作者:zhushangyuan_ ? 應(yīng)用場(chǎng)景 在應(yīng)用的使用和開(kāi)發(fā)中,彈窗是一個(gè)很常見(jiàn)的場(chǎng)景,自定義
    發(fā)表于 09-06 14:40

    OpenHarmony自定義組件介紹

    一、創(chuàng)建自定義組件 在ArkUI中,UI顯示的內(nèi)容均為組件,由框架直接提供的稱(chēng)為系統(tǒng)組件,由開(kāi)發(fā)者定義的稱(chēng)為自定義組件。在進(jìn)行 UI 界面開(kāi)發(fā)時(shí),通常不是簡(jiǎn)單的將系統(tǒng)組件進(jìn)行組合使用,
    發(fā)表于 09-25 15:36

    1602自定義字符

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

    三種自定義彈窗UI組件封裝的實(shí)現(xiàn)

    鴻蒙已經(jīng)提供了全局 UI 方法自定義彈窗,本文是基于基礎(chǔ)的自定義彈窗來(lái)實(shí)現(xiàn)提示消息彈窗、確認(rèn)彈窗
    的頭像 發(fā)表于 03-30 09:28 ?3500次閱讀

    自定義視圖組件教程案例

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

    labview自定義控件

    labview自定義精美控件
    發(fā)表于 05-15 16:46 ?18次下載

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

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

    自定義算子開(kāi)發(fā)

    一個(gè)完整的自定義算子應(yīng)用過(guò)程包括注冊(cè)算子、算子實(shí)現(xiàn)、含自定義算子模型轉(zhuǎn)換和運(yùn)行含自定義op模型四個(gè)階段。在大多數(shù)情況下,您的模型應(yīng)該可以通過(guò)使用hb_mapper工具完成轉(zhuǎn)換并順利部署到地平線(xiàn)芯片上……
    的頭像 發(fā)表于 04-07 16:11 ?3202次閱讀
    <b class='flag-5'>自定義</b>算子開(kāi)發(fā)

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

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

    鴻蒙ArkUI開(kāi)發(fā)-應(yīng)用添加彈窗

    彈窗是一種模態(tài)窗口,通常用來(lái)展示用戶(hù)當(dāng)前需要的或用戶(hù)必須關(guān)注的信息或操作。在彈出框消失之前,用戶(hù)無(wú)法操作其他界面內(nèi)容。ArkUI為我們提供了豐富的彈窗功能
    的頭像 發(fā)表于 01-24 17:22 ?1012次閱讀
    鴻蒙<b class='flag-5'>ArkUI</b>開(kāi)發(fā)-應(yīng)用添加<b class='flag-5'>彈窗</b>

    鴻蒙ArkUI實(shí)例:【自定義組件】

    組件是 OpenHarmony 頁(yè)面最小顯示單元,一個(gè)頁(yè)面可由多個(gè)組件組合而成,也可只由一個(gè)組件組合而成,這些組件可以是ArkUI開(kāi)發(fā)框架自帶系統(tǒng)組件,比如?`Text`?、?`Button`?等,也可以是自定義組件,本節(jié)筆者簡(jiǎn)單介紹一下
    的頭像 發(fā)表于 04-08 10:17 ?977次閱讀