#pragma mark - 实现delegate中的方法 <UINavigationControllerDelegate>
// 清除系统tabBarButton上的badgeView (每次导航控制器跳转时显示VC前都会调用)
- (void)navigationController:(UINavigationController *)navigationController
willShowViewController:(UIViewController *)viewController
animated:(BOOL)animated
{
//获取主窗口的根控制器tabBarController
UITabBarController *tabBarController = (UITabBarController *)[UIApplication sharedApplication].keyWindow.rootViewController;
// 移除系统tabBarButton上的badgeView
for (UIView *view in tabBarController.tabBar.subviews) {
for (UIView *subview in view.subviews) {
if ([subview isKindOfClass: NSClassFromString(@"_UIBadgeView")]) {
[subview removeFromSuperview];
}
}
}
}