Skip to content

Instantly share code, notes, and snippets.

@vackup
Forked from pierceboggan/CustomUIBarButtonItem.cs
Created September 22, 2016 14:15
Show Gist options
  • Save vackup/6c43a9cc008d5fcb03158f8b2b81809e to your computer and use it in GitHub Desktop.
Save vackup/6c43a9cc008d5fcb03158f8b2b81809e to your computer and use it in GitHub Desktop.
Shows off using a UIButton with a background image as a UIBarButtonItem, and handling touch events accordingly.
var composeButton = new UIButton (new RectangleF (0, 0, 20, 20));
composeButton.SetBackgroundImage (Images.ComposeButton, UIControlState.Normal);
composeButton.SetBackgroundImage (Images.ComposeButtonHighlighted, UIControlState.Highlighted);
composeButton.AddTarget((object sender, EventArgs args) => PresentViewController (new PrayerComposeDialog (), true, null),
UIControlEvent.TouchUpInside);
ComposeButton = new UIBarButtonItem (composeButton);
NavigationItem.RightBarButtonItem = ComposeButton;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment