05navigation的转场动画
·
起始页配置
// 配置共享元素id
起始页面为NavDestination或者Navigation都行但是推荐前者后者会出现两段动画
Image($r("app.media.background"))
.height(100)
.width(100)
.borderRadius(20)
.geometryTransition("shareID");
Button("to hello").onClick((event: ClickEvent) => {
// this.nav.pushPathByName('hello',this.helloParam,true)
this.getUIContext().animateTo({ duration: 500 }, () => {
this.nav.pushPathByName("hello", this.helloParam, false);
});
});
目标页面
import { AppStorageV2 } from "@kit.ArkUI"
@Builder
function worldBuilder(){
world()
}
@ComponentV2
export struct world{
@Consumer('nav')nav:NavPathStack = new NavPathStack()
build() {
NavDestination(){
Column(){
Image($r('app.media.background'))
.height(300)
.width(300)
.borderRadius(20)
.geometryTransition("shareID") //关键
}
}
.title("world")
}
}
更多推荐


所有评论(0)