How to add Badges on UIBarbutton item?

前端 未结 10 1739
广开言路
广开言路 2020-11-28 21:29

Hi friends am new to iphone developing. Am struggle with add badge values on UIBarbutton item on right side. I have tried but i can\'t solve this problem. Can anyone help me

10条回答
  •  囚心锁ツ
    2020-11-28 21:34

    After searching too many solutions I found this best solution for Objective-C

    Goto Following Link and download two files "UIBarButtonItem+Badge.h" and "UIBarButtonItem+Badge.m" and add to your project :

    https://github.com/mikeMTOL/UIBarButtonItem-Badge

    Then import in your class :

    #import "UIBarButtonItem+Badge.h"
    

    And write down following line to add badge :

    self.navigationItem.rightBarButtonItem.badgeValue = @"1"; //your value 
    

    Hope it will Work !!!

提交回复
热议问题