[英]How to Work with PopAsync page navigation animation from right to left?
請告訴我調用PopAsync()時如何應用從右到左的動畫頁面效果。
我的代碼:
async void LogOut_Tapped(object sender, EventArgs e)
{
await Navigation.PopAsync();
}
請幫我。
PopAsync
有一個重寫 ,它接受一個布爾值以指示是否應設置動畫。 如果使用Navigation.PopAsync(true)
調用它,則它將在彈出頁面時執行動畫。
您可以嘗試https://github.com/AlexandrNikulin/AnimationNavigationPage驚人的庫
用法
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 };
}
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.