如何更改 iOS UITabBar 徽章值位置?

How to change the iOS UITabBar badge value position?

这是我的代码 AppDelegate.m:

RootTableViewController *fcTableViewController = [[RootTableViewController alloc]
                                                  initWithStyle:UITableViewStylePlain];
fcTableViewController.title = @"root";
UINavigationController *fcNavigationController = [[UINavigationController alloc]
                                                  initWithRootViewController:fcTableViewController];
fcNavigationController.navigationBar.translucent = NO;
fcNavigationController.tabBarItem.badgeValue = @"0";

// ?
fcNavigationController.tabBarItem.image = [[UIImage imageNamed:@"icon1"]
                                           imageWithRenderingMode:UIImageRenderingModeAlwaysOriginal];
fcNavigationController.tabBarItem.imageInsets = UIEdgeInsetsMake(6, 0, -6, 0);

FaiChouViewController *fcViewController = [[FaiChouViewController alloc] init];
UINavigationController *fcNController = [[UINavigationController alloc] initWithRootViewController:fcViewController];
fcNController.navigationBar.translucent = YES;
fcNController.tabBarItem.badgeValue = @"1";
// ...
UITabBarController *fcTabBarController = [[UITabBarController alloc] init];
fcTabBarController.viewControllers = @[fcNavigationController, fcNController, fcpNavigationController];

self.window.rootViewController = fcTabBarController;

这是我的问题:

为什么我的 phone 上的徽章值 1 位置不正确?

以及如何解决?

前天我遇到了同样的问题,你可以看看here

演示

只需两行代码即可让您入门

- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {

  //supplying the animation parameter
  [UITabBarItem setDefaultAnimationProvider:[[DefaultTabbarBadgeAnimation alloc] init]];
  [UITabBarItem setDefaultConfigurationProvider:[[DefaultSystemLikeBadgeConfiguration alloc] init]];

  //rest of your code goes following...

  return YES;
}