iOS13修改tabbar的顶部分割线颜色、选中的item图片及颜色

if (@available(iOS 13.0, *)) {
        
        UITabBarAppearance *appearance = [UITabBarAppearance new];
        // 修改tabbar顶部分割线的颜色
        appearance.shadowColor = kColor_F2F2F2;
        appearance.backgroundColor = [UIColor whiteColor];
        
        NSMutableParagraphStyle *style = [[NSMutableParagraphStyle alloc] init];
        style.alignment = NSTextAlignmentCenter;
        
        UITabBarItemStateAppearance *normalAppearance = appearance.stackedLayoutAppearance.normal;
        normalAppearance.titleTextAttributes = @{NSForegroundColorAttributeName:kColor_999999, NSParagraphStyleAttributeName: style};
        // 修改文字到图片的距离
        normalAppearance.titlePositionAdjustment = UIOffsetMake(0, -4);
        
        UITabBarItemStateAppearance *selectedAppearance = appearance.stackedLayoutAppearance.selected;
        selectedAppearance.titleTextAttributes = @{NSForegroundColorAttributeName:kColor_FFCB12, NSParagraphStyleAttributeName: style};
        selectedAppearance.titlePositionAdjustment = UIOffsetMake(0, -4);
        
        self.tabBar.standardAppearance = appearance;
        
    }

你可能感兴趣的:(iOS13修改tabbar的顶部分割线颜色、选中的item图片及颜色)