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;
        
    }
©著作权归作者所有,转载或内容合作请联系作者
平台声明:文章内容(如有图片或视频亦包括在内)由作者上传并发布,文章内容仅代表作者本人观点,简书系信息发布平台,仅提供信息存储服务。

推荐阅读更多精彩内容