解决系统的badgeView

来源:互联网 发布:你的名字发绳淘宝 编辑:程序博客网 时间:2024/04/29 02:47

#pragma mark - 实现delegate中的方法  <UINavigationControllerDelegate>


// 清除系统tabBarButton上的badgeView (每次导航控制器跳转时显示VC前都会调用)

- (void)navigationController:(UINavigationController *)navigationController

      willShowViewController:(UIViewController *)viewController

                    animated:(BOOL)animated

{

    //获取主窗口的根控制器tabBarController

    UITabBarController *tabBarController = (UITabBarController *)[UIApplicationsharedApplication].keyWindow.rootViewController;

    

    // 移除系统tabBarButton上的badgeView

    for (UIView *viewin tabBarController.tabBar.subviews) { 

        

        for (UIView *subviewin view.subviews) {

            

            if ([subview isKindOfClass: NSClassFromString(@"_UIBadgeView")]) {


                [subview removeFromSuperview];

            }

        }

    }

}


0 0
原创粉丝点击