您的位置:首页 > 财经 > 金融 > HarmonyOS interface router scale pageTransition SlideEffect.Left ArkTS ArkUI

HarmonyOS interface router scale pageTransition SlideEffect.Left ArkTS ArkUI

2024/11/17 14:46:14 来源:https://blog.csdn.net/lmnotlm/article/details/139157427  浏览:    关键词:HarmonyOS interface router scale pageTransition SlideEffect.Left ArkTS ArkUI

在这里插入图片描述

🎬️create

@Component
export  default struct TitleBar {build(){Row(){Text('transition').fontSize('30fp').fontColor(Color.White)}.width('100%').height('8%').backgroundColor('#4169E1').padding({left:10})}}

🎞️interface

export  interface IList{title:string;url :string;
}
  @State listData:IList[]=[ //  @State listData:Array<IList>=[{title:'in',url:'pages/home1'},{title:'scale',url:'pages/home2'},{title:'small',url:'pages/home3'},{title:'in',url:''}]

💡foreach

   ForEach(this.listData,( item: IList,index?:number)=>{//listitemButton({type:ButtonType.Capsule}){Text(item.title).fontSize('35fp').fontColor(Color.White)}//...})

🔦router

import router from '@ohos.router'

📼mainpage

  "pages/home1"

📹️onclick

 .onClick(()=>{//routerrouter.pushUrl({url:item.url})})

📺️setInterval

//home1  page1
import  router from '@ohos.router'
@Entry
@Component
struct Index {@State TOTAL_TIME:number = 6;//s@State FIRST_CT:number =3;//saboutToAppear(){//timerlet timer=   setInterval(()=>{this.TOTAL_TIME--;if(this.TOTAL_TIME===0){//endrouter.pushUrl({url:"pages/Index"})clearInterval(timer);}},1000)}build() {Column() {Row() {if(this.TOTAL_TIME>this.FIRST_CT){//1Image($r('app.media.t2')).objectFit(ImageFit.Contain)}else if(this.TOTAL_TIME<this.FIRST_CT) {//2Image($r('app.media.bc')).objectFit(ImageFit.Contain).width('30%')Text(' - m - ').fontSize('30fp')}}.width('100%').height('100%').justifyContent(FlexAlign.Center)// Text('in')//   .fontSize('50fp')}.width('100%')}
}

-----------

📽️TransitionEnter scale

//home2 page2@State scale1: number = 1@State opacity1: number = 1
//...Column()
.scale({ x: this.scale1 }).opacity(this.opacity1)
//...pageTransition() {PageTransitionEnter({ duration: 1200, curve: Curve.Linear }).onEnter((type: RouteType, progress: number) => {this.scale1 = 1this.opacity1 = progress}) // onEnter (0% -- 100%)PageTransitionExit({ duration: 1500, curve: Curve.Ease }).onExit((type: RouteType, progress: number) => {this.scale1 = 1 - progressthis.opacity1 = 1}) // onExit (0% -- 100%)}

在这里插入图片描述

🎥SlideEffect.Left

  pageTransition() {PageTransitionEnter({ duration: 1200 }).slide(SlideEffect.Left)PageTransitionExit({ delay: 100 }).translate({ x: 100.0, y: 100.0 }).opacity(0)}

在这里插入图片描述

版权声明:

本网仅为发布的内容提供存储空间,不对发表、转载的内容提供任何形式的保证。凡本网注明“来源:XXX网络”的作品,均转载自其它媒体,著作权归作者所有,商业转载请联系作者获得授权,非商业转载请注明出处。

我们尊重并感谢每一位作者,均已注明文章来源和作者。如因作品内容、版权或其它问题,请及时与我们联系,联系邮箱:809451989@qq.com,投稿邮箱:809451989@qq.com