Displaying notification badge like counter in UINavigationbar

后端 未结 3 1366
慢半拍i
慢半拍i 2021-01-25 07:09

I have a requirement to display number of pending notifications in iPhone navigation bar. The appearance should be like that of notification badge - but these are not APNS notif

3条回答
  •  暖寄归人
    2021-01-25 07:43

    First get the respective barbuttonitem in navigationController by

    let baritem = navigationItem.right/leftBarButtonItem
    baritem.badgeValue = "\(correspondingValues)"
    

提交回复
热议问题