Search code examples
iosswiftuitabbaritembadge

Adjust UITabBarItem Badge position?


I change badge position with this code:

for tabBarButton in self.tabBar.subviews{
            for badgeView in tabBarButton.subviews{
                let className=NSStringFromClass(badgeView.classForCoder)
                if  className == "_UIBadgeView"
                {
                    badgeView.layer.transform = CATransform3DIdentity
                    badgeView.layer.transform = CATransform3DMakeTranslation(-5.0, 1.0, 1.0)
                }
            }
        }

As I found here

I need change it frequently. As a result, the badge jumps:

http://www.giphy.com/gifs/3og0ILQSxcXE8QucFi


Solution

  • I started do this cycle every time, when I change a badge value. All is fine now, except little visible shift on start.