我使用Xamarin.Forms创建简单的应用程序,并需要将导航设置为up&左下角对了
答案 0 :(得分:1)
如果你想要&向下动画(不是自定义动画),您只需使用Navigation.PushModalAsync(page)
来显示页面。
此外,我刚刚编写了一个自定义渲染器来改变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);
}
}
}