c# - 在 Xamarin Shell 中的标签栏页面之间滑动
问题描述
我使用底部菜单并禁用弹出窗口。对于 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)
{
}
}
}```
![enter image description here](https://i.stack.imgur.com/dXNMJ.gif)
解决方案
推荐阅读
- git - git clone 主权限644,克隆权限777
- java - 如何为静态 void 方法实现 doNothing()?
- c - 函数内的静态变量是否会超出范围?
- azure - azure VM 上访问烧瓶应用程序超时
- angular - rxjs observable subscribe 什么时候同步执行?
- javascript - 尝试使用 React Native 向 Flask 后端发出 Axios HTTP 请求
- javascript - 如何在字符串中插入换行符-Javascript
- swift - 有没有办法链接 SceneKit 动画?
- go - 如何使用任意或不推荐的扩展名签署证书
- excel - 输入的位置重要吗?(SUMIFS)