Xamarin.forms页面之间导航的自定义动画? [英] custom animation for navigation between pages Xamarin.forms?
本文介绍了Xamarin.forms页面之间导航的自定义动画?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我使用Xamarin.Forms创建了简单的App,需要将导航设置为&左&的下州正确
I create simple App using Xamarin.Forms and need to set the navigation to up & down instate of left & right
推荐答案
如果您想要&下动画(不是自定义动画),您只需使用Navigation.PushModalAsync(page)
即可显示页面.
If you want up & down animation (not custom animation), you could simply use Navigation.PushModalAsync(page)
to present the page .
此外,我刚刚编写了一个自定义渲染器来更改iOS上的动画.
Besides, I just wrote a custom renderer to change animation on iOS.
[assembly: ExportRenderer(typeof(NavigationPage), typeof(AnimationNavigationRenderer))]
class AnimationNavigationRenderer : NavigationRenderer
{
public override void PushViewController(UIViewController viewController, bool animated)
{
if (animated)
{
// Alternative way with different set of trannsition
/*
UIView.Animate(0.75, () =>
{
UIView.SetAnimationCurve(UIViewAnimationCurve.EaseInOut);
base.PushViewController(viewController, false);
UIView.SetAnimationTransition(UIViewAnimationTransition.CurlUp, this.View, false);
});
*/
var transition = CATransition.CreateAnimation();
transition.Duration = 0.75;
transition.Type = CAAnimation.TransitionPush;
View.Layer.AddAnimation(transition, null);
base.PushViewController(viewController, false);
}
else
{
base.PushViewController(viewController, false);
}
}
public override UIViewController PopViewController(bool animated)
{
if (animated)
{
// Alternative way with different set of trannsition
/* UIView.Animate(0.75, () =>
{
UIView.SetAnimationCurve(UIViewAnimationCurve.EaseInOut);
UIView.SetAnimationTransition(UIViewAnimationTransition.CurlDown, this.View, false);
});
*/
var transition = CATransition.CreateAnimation();
transition.Duration = 0.75;
transition.Type = CAAnimation.TransitionFromTop;
View.Layer.AddAnimation(transition, null);
return base.PopViewController(false);
}
else
{
return base.PopViewController(false);
}
}
}
https://gist.github.com/alexlau811/e12a8c126e6e082a5017
这篇关于Xamarin.forms页面之间导航的自定义动画?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文