HeisenBerg HeisenBerg - 1 year ago 405
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.

Answer Source

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

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download