How to adjust tab bar badge position?

前端 未结 6 1887
鱼传尺愫
鱼传尺愫 2021-01-12 07:57

I\'m displaying badge on tab bar but when number increase it goes out to tab bar item like shown in image

\"this

6条回答
  •  不要未来只要你来
    2021-01-12 08:32

    Badge align to your tab bar image by default.If you add large image as tab bar item image you can adjust it's using following code.

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

提交回复
热议问题