Xamarin表单自定义导航过渡

时间:2017-06-29 15:16:39

标签: c# xamarin xamarin.ios xamarin.forms

我知道之前已经提出过这个问题,但大多数都来自一年多以前,我想知道问题是否仍然存在。

Xamarin表单是否仍然不支持自定义导航页面转换?

我知道你可以在本机应用程序中很好地制作动画但是从我的研究中可以看出,Xamarin Forms需要一个自定义渲染器或包来进行简单的自定义页面转换。这种情况有所改变还是仍然是常态?希望他们提出某种形式的支持,因为这些线程被问到了。

由于

1 个答案:

答案 0 :(得分:1)

Xamarin.Forms没有能力做到这一点,但有一个解决方法。

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

像这样:

// 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