Xamarin.iOS侧滑菜单SlideoutNavigation控件


Xamarin.iOS侧滑菜单控件——SlideoutNavigation

Xamarin.iOS


iOS侧滑菜单已然不是什么新鲜事,但想在xamarin实现却不是件简单的事,今天分享一下在项目中使用到的第三方的开源控件SlideoutNavigation,SlideoutNavigation的使用相当简单,只需在FinishedLaunching中简单配置一下侧边栏菜单及主菜单方可使用,兼容iOS6、7:

1.源码地址(github):SlideoutNavigation
2.使用方法:

  1. public override bool FinishedLaunching (UIApplication app, NSDictionary options)
  2. {
  3. window = new UIWindow (UIScreen.MainScreen.Bounds);
  4. Menu = new SlideoutNavigationController ();
  5. Menu.SlideHeight = 9999f;
  6. Menu.TopView = new HomeViewController ();
  7. Menu.MenuViewLeft = new DummyControllerLeft ();
  8. Menu.MenuViewRight = new DummyControllerRight ();
  9. window.RootViewController = Menu;
  10. window.MakeKeyAndVisible ();
  11. return true;
  12. }

3.部分可设属性
1)左右按钮显示

  1. Menu.DisplayNavigationBarOnRightMenu = false;
  2. Menu.DisplayNavigationBarOnLeftMenu = false;
  3. 2)设置导航条菜单图标
  4. [csharp] view plain copy CODE上查看代码片派生到我的代码片
  5. /// <summary>
  6. /// Creates the menu button for the left side.
  7. /// </summary>
  8. protected virtual UIBarButtonItem CreateLeftMenuButton ()
  9. {
  10. //你需要自定义按钮图标
  11. UIImage imgMenu = ViewStyle.GetModelImage (ModelImageEnum.Common, "btn_menu.png");
  12. UIButton menuBtn = new UIButton (UIButtonType.Custom);
  13. menuBtn.Frame = new RectangleF (0, 0, imgMenu.Size.Width, imgMenu.Size.Height);
  14. menuBtn.SetBackgroundImage (imgMenu, UIControlState.Normal);
  15. menuBtn.TouchUpInside += delegate {
  16. ShowMenuLeft ();
  17. } ;
  18. return new UIBarButtonItem (menuBtn);
  19. }

20140630115722843.jpg-24.2kB
20140630115731015.jpg-24.6kB
20140630115737203.jpg-26.4kB

作者:zhaowensky_126
原文地址:http://blog.csdn.net/zhaowensky_126/article/details/35988531

分享到