How to add icon to UINavigationItem (UIBarButtonItem) - Swift 3

Dose ios provide icon on UIBarButtonItem? if not how to do it programmatically or use any library (which is the best library) Screen

In the image, I want to show the icon on the UIBarButtonItem (refresh button icon) as red, round or numbers.

+3


source to share


1 answer


I am using MIBadgeButton it works like a charm.



var appNotificationBarButton: MIBadgeButton!      // Make it global
self.appNotificationBarButton = MIBadgeButton(frame: CGRect(x: 0, y: 0, width: 50, height: 40))
self.appNotificationBarButton.setImage(UIImage(named: "bell"), for: .normal)
self.appNotificationBarButton.badgeEdgeInsets = UIEdgeInsetsMake(10, 0, 0, 10)
self.appNotificationBarButton.addTarget(self, action: #selector(self.appNotificationClicked), for: .touchUpInside)
let App_NotificationBarButton : UIBarButtonItem = UIBarButtonItem(customView: self.appNotificationBarButton)
self.navigationItems.rightBarButtonItem = App_NotificationBarButton

      

+3


source







All Articles