Xamarin形成自定义导航过渡 [英] Xamarin Forms Custom Navigation Transitions

查看:66
本文介绍了Xamarin形成自定义导航过渡的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我知道这个问题以前曾被问过,但其中大多数是一年多以前的,我想知道问题是否仍然存在.

I am aware that this question has been asked before but most of them are from over a year ago and I am wondering whether the issue still persists.

Xamarin Forms是否仍不支持自定义导航页面过渡?

Does Xamarin Forms still provide no support on custom navigation page transitions?

我知道您可以在本机应用程序中很好地制作动画,但是从我的研究看来,Xamarin Forms需要自定义渲染器或程序包来执行简单的自定义页面转换.这有没有改变?还是这仍然是常态?希望自问到这些线程以来,他们增加了某种形式的支持.

I know that you can make animations well in the native applications but it seems from my research that Xamarin Forms requires either a custom renderer or package for doing a simple custom page transition. Has this changed at all or is that still the norm? Hoping they added some form of support since those threads were asked.

谢谢

推荐答案

Xamarin.Forms无法执行此操作,但是有一种解决方法.

Xamarin.Forms doesn't have the capability to do that, but there's a workaround.

如果在推入或弹出"页面时禁用了动画过渡,则可以在过渡之前/之后进行自定义动画.

If you disable the animation transition when Pushing or Popping pages, you can do your custom animation before/after the transition.

像这样:

// 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动画,您就可以开始了:)

You can apply this concept to do any kind of animation, just instead of modifying the opacity, modify the TranslationY, TranslationX, etc. And if you want a complex animation, you can modify more than one at the same time too, just take your time to learn Xamarin.Forms animation and you're good to go :)

希望有帮助!:D

这篇关于Xamarin形成自定义导航过渡的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆