1

I have a requirement where I need to show the badge number on top of the right navigation button. Something like this:

enter image description here

How to show the badge on top of UIBarButtonItem in the navigation bar?

I am still using Xcode 7.3.1, Swift 2.2.

Eric Aya
  • 69,473
  • 35
  • 181
  • 253
bably
  • 1,065
  • 5
  • 17
  • 27
  • Simply user interface drag imageview and set image and then set label on top right position and then change layer of label to make it circular , and then set number on it , simple – Shobhakar Tiwari Sep 27 '16 at 09:52
  • 1
    It needs to be in the navigation bar - the badge on top right of right UIBarButtonItem. So I cant simply do it. – bably Sep 27 '16 at 09:56
  • why not ! under navigationbar , drag bar item and then drag imageview and label inside it , did u try this – Shobhakar Tiwari Sep 27 '16 at 09:58
  • 1
    under navigationbar , drag bar item - I did till that. But later I am not able to drag a imageview and a label inside it. I have tried it but its not working. – bably Sep 27 '16 at 10:12
  • @ShobhakarTiwari U need to learn something. Drag image on navigation bar button wont work – Gajendra K Chauhan Aug 20 '17 at 19:39

1 Answers1

1

I am working with this Framework here:

https://github.com/enmiller/ENMBadgedBarButtonItem-Swift

Otherwise you could create your own View with a Badge. Just make an Custom UINavigationItem.

For example:

let rightBarButton = UIBarButtonItem(customView: AnyOfYourCustomViews)
derdida
  • 14,784
  • 16
  • 90
  • 139