Skip to content

fulldecent/YTBarButtonItemWithBadge

 
 

Repository files navigation

YTBarButtonItemWithBadge

Simple UIBarButtonItem with badge support

alt text

Installation

Add this to your project using Swift Package Manager. In Xcode that is simply: File > Swift Packages > Add Package Dependency... and you're done. Alternative installations options are shown below for legacy projects.

CocoaPods

If you are already using CocoaPods, just add 'YTBarButtonItemWithBadge' to your Podfile then run pod install.

Usage

func viewDidLoad() {
  let buttonWithBadge = YTBarButtonItemWithBadge();
  buttonWithBadge.setHandler(callback: onClick);
  buttonWithBadge.setImage(image: UIImage(named: "icon.png")!);
  buttonWithBadge.setTitle(value: "My Button");
  buttonWithBadge.setBadge(value: "10");
  self.navigationItem.setRightBarButton(buttonWithBadge.getBarButtonItem(), animated: true);
}

func onClick() {
  //Do stuff
}
Icons made by Freepik from www.flaticon.com

About

Simple UIBarButtonItem with badge support

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages

  • Swift 79.7%
  • Shell 13.0%
  • Ruby 7.3%