iOS13 Tabbar 文字偏移 title文字颜色设置问题

更新后查看tabbar 发现在iOS13下tabbar 文字发生偏移 并且颜色变为系统默认颜色 

解决方法:

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

        UITabBarAppearance *appearance = UITabBarAppearance.new;

        NSMutableParagraphStyle *par = [[NSMutableParagraphStyle alloc]init];

        par.alignment = NSTextAlignmentCenter;

        UITabBarItemStateAppearance *normal = appearance.stackedLayoutAppearance.normal;

        if(normal) {

            normal.titleTextAttributes = @{NSForegroundColorAttributeName:[<你要设置的默认颜色>],NSParagraphStyleAttributeName : par};

        }

            UITabBarItemStateAppearance *selected = appearance.stackedLayoutAppearance.selected;

        if(selected) {

            selected.titleTextAttributes = @{NSForegroundColorAttributeName:[<你要设置的选中颜色>],NSParagraphStyleAttributeName : par};

        }

        self.tabBar.standardAppearance= appearance;

        }

你可能感兴趣的:(iOS13 Tabbar 文字偏移 title文字颜色设置问题)