How to adjust tab bar badge position?

前端 未结 6 1844
鱼传尺愫
鱼传尺愫 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:23

    In Objective-C:

        for (UIView *tabBarButton in self.navigationController.tabBarController.tabBar.subviews)
        {
            for (UIView *badgeView in tabBarButton.subviews)
            {
                NSString *className = NSStringFromClass([badgeView class]);
    
                // Looking for _UIBadgeView
                if ([className rangeOfString:@"BadgeView"].location != NSNotFound)
                {
                    badgeView.layer.transform = CATransform3DIdentity;
                    badgeView.layer.transform = CATransform3DMakeTranslation(-5.0, 1.0, 1.0);
                }
            }
        }
    

提交回复
热议问题