[英]Xamarin Forms Custom Navigation Transitions
我知道之前有人问过这个问题,但其中大部分是一年多以前的问题,我想知道问题是否仍然存在。
Xamarin Forms 仍然不支持自定义导航页面转换吗?
我知道您可以在本机应用程序中很好地制作动画,但从我的研究来看,Xamarin Forms 需要自定义渲染器或包来执行简单的自定义页面转换。 这完全改变了还是仍然是常态? 希望他们在询问这些线程后添加了某种形式的支持。
谢谢
Xamarin.Forms 没有能力做到这一点,但有一种解决方法。
如果在 Pushing 或 Popping 页面时禁用动画过渡,则可以在过渡之前/之后执行自定义动画。
像这样:
// First animate the opacity of the current page
new Animation(opacity => page.Opacity = opacity / 100, 100, 0)
.Commit(this, "PageExitAnimation", 1, 350, Easing.CubicInOut, (d, b) =>
{
var otherPage = new OtherPage() { Opacity = 0 }; // Create the page with 0 opacity to animate later
NavigationPage.Navigation.PushAsync(otherPage, false); // Push the new page, as the current page is already with 0 opacity, without animation
otherPage.FadeTo(1, 350, Easing.CubicInOut); // Animate the fade of the next page
}
你可以应用这个概念来做任何类型的动画,而不是修改不透明度,修改TranslationY,TranslationX等。如果你想要一个复杂的动画,你也可以同时修改多个,只需是时候学习 Xamarin.Forms 动画了,一切顺利:)
希望有帮助! :D
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.