请告诉我调用 PopAsync() 时如何应用从右到左的动画页面效果。
我的代码:
async void LogOut_Tapped(object sender, EventArgs e)
{
await Navigation.PopAsync();
}
请帮助我。
你可以尝试https://github.com/AlexandrNikulin/AnimationNavigationPage 惊人的库。以下代码块来自项目自述文件(可能略有改编,归功于Alexandr Nikulin):
用法
public class App : Application
{
public App()
{
MainPage = new AnimationNavigationPage(new YourHomePage());
}
}
创建 AnimationPage 而不是 ContentPage 并在 xaml 中创建 FadePageAnimation 或 PushPageAnimation 或 FlipPageAnimation 等实例或从 ViewModel 绑定。
<?xml version="1.0" encoding="UTF-8"?>
<controls:AnimationPage xmlns="http://xamarin.com/schemas/2014/forms"
xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
xmlns:controls="clr-namespace:FormsControls.Base;assembly=FormsControls.Base"
x:Class="Sample.FadeAnimationPage"
Title="Fade Animation">
<controls:AnimationPage.PageAnimation>
<controls:FadePageAnimation />
</controls:AnimationPage.PageAnimation>
</controls:AnimationPage>
或者为ContentPage实现接口IAnimationPage。创建 EmptyPageAnimation 或 DefaultPageAnimation 或 FlipPageAnimation 等实例...
public partial class FirstPage : ContentPage, IAnimationPage
{
public FirstPage()
{
InitializeComponent();
}
public IPageAnimation PageAnimation { get; } = new FlipPageAnimation { Duration = 650, Subtype = AnimationSubtype.FromLeft };
}