iOS13去除TabBar顶部那根线

// 去除顶部那根线

    [UITabBar appearance].translucent = NO;

    if(@available(iOS13.0, *)) {

       UITabBarAppearance *appearance = [UITabBarAppearance new];

       appearance.backgroundColor = [UIColor whiteColor];

       appearance.backgroundImage= [UIImagenew];

       appearance.shadowColor = [UIColor clearColor];

       appearance.shadowImage= [UIImagenew];

       UITabBarItemStateAppearance *normal = appearance.stackedLayoutAppearance.normal;

       if(normal) {

           normal.titleTextAttributes = @{NSForegroundColorAttributeName:KRGBACOLOR(123, 123, 123, 1),NSFontAttributeName:second_font};

       }

       UITabBarItemStateAppearance *selected = appearance.stackedLayoutAppearance.selected;

       if(selected) {

           selected.titleTextAttributes = @{NSForegroundColorAttributeName:KRGBACOLOR(78, 126, 215, 1),NSFontAttributeName:second_font};

       }

       self.tabBar.standardAppearance = appearance;


    }else{

       [[UITabBarItem appearance] setTitleTextAttributes:@{NSForegroundColorAttributeName:KRGBACOLOR(123, 123, 123, 1),NSFontAttributeName:second_font} forState:UIControlStateNormal];

       [[UITabBarItem appearance] setTitleTextAttributes:@{NSForegroundColorAttributeName:KRGBACOLOR(78, 126, 215, 1),NSFontAttributeName:second_font} forState:UIControlStateSelected];

    }




注意:

       self.tabBar.standardAppearance = appearance;

这一句要放在设置完之后,才会生效,不然就会有蓝色文字的出现

你可能感兴趣的:(iOS13去除TabBar顶部那根线)