2017-06-14 68 views
3

在UIBarButtonItem上提供徽章的剂量ios? 如果没有那么如何以编程方式做到这一点,或使用任何库(什么是最好的图书馆) Screen如何将徽章添加到UINavigationItem(UIBarButtonItem) - Swift 3

在图像我想告诉喜欢红色的圆形或数字的任何事情上的UIBarButtonItem徽章(刷新按钮图标)。

+1

@rkkanojai我不认为ios在UIBarButtonItem上提供了徽章号码。您需要添加一个标签来显示徽章数量。 – Developer

回答

3

我使用MIBadgeButton其工作就像一个魅力。

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 
相关问题