Button Types
- View – Handles hiding and showing an attached view
- AutoDisposingView -Handles hiding and showing an attached view and removes the view from memory when it loses focus
- Tool – A button that has a user defined action when touched
- Notification – A non-touchable icon displayed in the bar
Available Regions
NavBar has three separate regions that you can add buttons to: Top, Middle and Bottom. NavBar automatically handles the spacing and placement of buttons within the regions and responds to UIInterfaceOrientation events with smoothly animated transitions.
Customizable Appearance
NavBar is fully customizable with user definable appearances for every element of its UI.
iOS Example
using Appracatappra.UIKit.NavBar;
...
public override void ViewDidLoad ()
{
UINavBarButton warning=null;
UINavBarButton delete=null;
UINavBarButton ticket;
base.ViewDidLoad ();
//Adjust the appearance of the NavBar
navBar.appearance.border = UIColor.Gray;
//Create a new view from code
UIImageView logo=new UIImageView(new RectangleF(70,10,512,512));
logo.Image=UIImage.FromFile ("Icon.png");
//----------------------------------------------------------------------------------------------------------------------------------
//Add buttons to the top of the bar
//----------------------------------------------------------------------------------------------------------------------------------
//The first button added to the top collection will automatically be selected
UINavBarButton home=navBar.top.AddButton (UIImage.FromFile ("Icons/house.png"), true, false);
//Wireup request for this button's view
home.RequestNewView+= delegate(UINavBarButton responder) {
//Attaching a view to a button will automatically display it under the NavBar
home.attachedView = logo;
};
//Add an action to the home button
home.Touched+= delegate(UINavBarButton responder) {
//Hide warning notification in NavBar
if (warning!=null) warning.Hidden=true;
//Disable the delete button
if (delete!=null) delete.Enabled=false;
};
//Request that the initial view being controlled by the NavBar be displayed
navBar.DisplayDefaultView ();
navBar.top.AddAutoDisposingButton (UIImage.FromFile ("Icons/bar-chart.png"), true, false).RequestNewView+= delegate(UINavBarButton responder) {
//Build new view from a .xib file and attach it to the button it will automatically
//be displayed under the NavBar
responder.attachedView=BarChartView.Factory (this);
};
navBar.top.AddButton (UIImage.FromFile ("Icons/orgchart.png"), true, false).RequestNewView+= delegate(UINavBarButton responder) {
responder.attachedView=OrgChartView.Factory (this);
};
(ticket= navBar.top.AddButton (UIImage.FromFile ("Icons/ticket.png"), true, false)).RequestNewView+= delegate(UINavBarButton responder) {
responder.attachedView=TicketView.Factory (this);
};
ticket.Touched+= delegate(UINavBarButton responder) {
//Enable the delete button
if (delete!=null) delete.Enabled=true;
};
//----------------------------------------------------------------------------------------------------------------------------------
//Add buttons to the middle of the bar
//----------------------------------------------------------------------------------------------------------------------------------
navBar.middle.AddTool (UIImage.FromFile ("Icons/printer.png"), true, false).Touched+= delegate(UINavBarButton responder) {
//Display Alert Dialog Box
using(var alert = new UIAlertView("NavBar", "Sorry but printing is not available at this time.", null, "OK", null))
{
alert.Show();
}
//Display warning notification in NavBar
if (warning!=null) warning.Hidden=false;
};
(delete = navBar.middle.AddTool (UIImage.FromFile ("Icons/trash.png"), false, false)).Touched += delegate(UINavBarButton responder) {
//Verify that the user really wants to stop downloading information
UIAlertView alert = new UIAlertView("NavBar", "Delete Item?", null, "Cancel", "OK");
//Wireup events
alert.CancelButtonIndex=0;
alert.Clicked += (sender, buttonArgs) => {
//Did the user verify termination?
if (buttonArgs.ButtonIndex==1) {
//Yes
delete.Enabled=false;
}
};
//Display dialog
alert.Show();
};
//----------------------------------------------------------------------------------------------------------------------------------
//Add buttons to the bottom of the bar
//----------------------------------------------------------------------------------------------------------------------------------
warning = navBar.bottom.AddNotification (UIImage.FromFile ("Icons/warning.png"), null, true);
navBar.bottom.AddButton (UIImage.FromFile ("Icons/gear.png"), true, false).RequestNewView+= delegate(UINavBarButton responder) {
responder.attachedView=SettingsView.Factory(this,navBar);
};
}