美文网首页
iOS13修改tabbar的顶部分割线颜色、选中的item图片及

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

作者: Desert_Eagle | 来源:发表于2019-09-29 09:40 被阅读0次
    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图片及

          本文链接:https://www.haomeiwen.com/subject/hvaxpctx.html