Simple UIBarButtonItem with badge support
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.
If you are already using CocoaPods, just add 'YTBarButtonItemWithBadge' to your Podfile then run pod install.
If you are already using Carthage, just add to your Cartfile:
github "https://github.com/fulldecent/YTBarButtonItemWithBadge" ~> 0.1
Then run carthage update to build the framework and drag the built FDWaveformView.framework into your Xcode project.
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
}
