当我在iOS中使用SwipeGestureRecognizer时如何在视图/页面之间添加过渡 用法

我正在像这样的ContentPage中使用ContentView

<ContentView x:Name="MyContent"
                         VerticalOptions="FillAndExpand"
                         HorizontalOptions="FillAndExpand">
                <ContentView.GestureRecognizers>
                    <SwipeGestureRecognizer Swiped="SwipLeft" Direction="Left"/>
                    <SwipeGestureRecognizer Swiped="SwipRight" Direction="Right"/>
                </ContentView.GestureRecognizers>
 </ContentView>

后面的代码中,我根据如下SwipeDirection将相关内容设置为ContentView。和SwipRight一样。

private void SwipLeft(object sender,SwipedEventArgs e)
        {
            
                if (e.Direction == SwipeDirection.Left)
                {
                   //set the relavent page content here               
                }                                      
        }

我需要设置动画或过渡效果,以在页面之间滑动时显示。我仅在iOS上需要它。任何人都可以帮我解决这个问题,或者任何方法都知道有人可以实现这一目标吗?

您可以从此快照中获得想法 click here for image 所有内容和一切都完成了,我只需要在页面之间添加过渡即可。

iCMS 回答:当我在iOS中使用SwipeGestureRecognizer时如何在视图/页面之间添加过渡 用法

您可以使用 TabbedPage 。看来您想让选项卡显示在屏幕顶部。您可以从nuget安装插件 TopTabbedPage

用法

<forms:TopTabbedPage
    xmlns="http://xamarin.com/schemas/2014/forms"
    xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
    x:Class="Naxam.Demo.TestPage"
    xmlns:views="clr-namespace:Naxam.Demo"
    xmlns:forms="clr-namespace:Naxam.Controls.Forms;assembly=Naxam.TopTabbedPage.Forms"
    BarTextColor="#00b9e1"
    BarIndicatorColor="#00b9e1"
    BarBackgroundColor="#ffffff"
    Title="MyRide">
    <views:Page1 />  // here is the content page,you need to put each contentview in independent ContenPage
    <views:Page2 />
</forms:TopTabbedPage>

在iOS项目中-> AppDelegate.cs

public override bool FinishedLaunching(UIApplication app,NSDictionary options)
    {
        // Override point for customization after application launch.
        // If not required for your application you can safely delete this method
        TopTabbedRenderer.Init();
       
        Xamarin.Forms.Forms.Init();

        LoadApplication(new App());

  
        return base.FinishedLaunching(app,options);
    }

有关该插件的更多详细信息,请参阅github project site

本文链接:https://www.f2er.com/1970915.html

大家都在问