Skip to content

Instantly share code, notes, and snippets.

@rotorgames
Created February 22, 2017 08:37
Show Gist options
  • Select an option

  • Save rotorgames/7119a8bcfe70e4a909e9809204782fe5 to your computer and use it in GitHub Desktop.

Select an option

Save rotorgames/7119a8bcfe70e4a909e9809204782fe5 to your computer and use it in GitHub Desktop.
Hamburger menu iOS
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using FreshWind.iOS.Renderers.NavigationPages;
using FreshWind.Views.NavigationPages;
using UIKit;
using Xamarin.Forms;
using Xamarin.Forms.Platform.iOS;
[assembly: ExportRenderer(typeof(FwNavigationPage), typeof(FwNavigationPageRenderer))]
namespace FreshWind.iOS.Renderers.NavigationPages
{
public class FwNavigationPageRenderer: NavigationRenderer
{
private bool _navBarSet;
private FwNavigationPage _element => (FwNavigationPage) Element;
public override UINavigationBar NavigationBar
{
get
{
if (_navBarSet)
return base.NavigationBar;
_navBarSet = RefreshHamburgerIcon();
return base.NavigationBar;
}
}
private bool RefreshHamburgerIcon()
{
if (base.NavigationBar.Items != null && base.NavigationBar.Items.Length > 0)
{
var item = base.NavigationBar.Items.FirstOrDefault();
if (item != null)
{
if (item.LeftBarButtonItems != null && item.LeftBarButtonItems.Length > 0)
{
var leftbutton = item.LeftBarButtonItems[0];
leftbutton.Image = new UIImage(_element.MenuIcon);
return true;
}
}
}
return false;
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment