我使用底部菜单并禁用弹出窗口。对于 IOS,我需要向 shell 添加滑动手势。我使用了自定义渲染。
如何添加滑动动画?在用于标签页的 Android 上,它开箱即用。对于 Xamarin Shell 选项卡栏菜单,我需要类似的东西。我认为 Xamarin Forms 很容易使用,没有任何问题。这是应该实施的基本事情
[assembly: ExportRenderer(typeof(AppShell), typeof(CustomShellRenderer))]
namespace ShellDemo.iOS
{
public class CustomShellRenderer : ShellRenderer
{
protected override IShellTabBarAppearanceTracker CreateTabBarAppearanceTracker()
{
return new CustomTabbarAppearance();
}
}
public class CustomTabbarAppearance : IShellTabBarAppearanceTracker
{
public void Dispose()
{
}
public void ResetAppearance(UITabBarController controller)
{
}
public void SetAppearance(UITabBarController controller, ShellAppearance appearance)
{
UISwipeGestureRecognizer swipeRight = new UISwipeGestureRecognizer((gesture) =>
{
if (controller.SelectedIndex > 0)
{
controller.SelectedIndex--;
}
});
swipeRight.Direction = UISwipeGestureRecognizerDirection.Right;
controller.View.AddGestureRecognizer(swipeRight);
UISwipeGestureRecognizer swipeLeft = new UISwipeGestureRecognizer((gesture) =>
{
if (controller.SelectedIndex < controller.ViewControllers.Count() - 1)
{
controller.SelectedIndex++;
}
});
swipeLeft.Direction = UISwipeGestureRecognizerDirection.Left;
controller.View.AddGestureRecognizer(swipeLeft);
}
public void UpdateLayout(UITabBarController controller)
{
}
}
}```
