HeisenBerg HeisenBerg - 1 month ago 13x
iOS Question

How to change UITabBarItem Badge position?

This is how my Tabbar is looking right now.

enter image description here

How do I move that badge so that it overlaps the top right of the bell icon? Any help is appreciated.


try this:

func repositionBadge(tabIndex: Int){

    for badgeView in self.tabBarController!.tabBar.subviews[tabIndex].subviews {

        if NSStringFromClass(badgeView.classForCoder) == "_UIBadgeView" {
            badgeView.layer.transform = CATransform3DIdentity
            badgeView.layer.transform = CATransform3DMakeTranslation(-17.0, 1.0, 1.0)

pay attention, tabIndex starts from 1