iOS开发之iOS13的适配(tabbar)

 if (@available(iOS 13.0, *)) {
        UITabBarAppearance *appearance = UITabBarAppearance.new;
        
        NSMutableParagraphStyle *par = [[NSMutableParagraphStyle alloc]init];
        par.alignment = NSTextAlignmentCenter;
        
        UITabBarItemStateAppearance *normal = appearance.stackedLayoutAppearance.normal;
        if (normal) {
            normal.titleTextAttributes = @{NSForegroundColorAttributeName:kFontBlue,NSParagraphStyleAttributeName : par};
        }
        
        UITabBarItemStateAppearance *selected = appearance.stackedLayoutAppearance.selected;
        if (selected) {
            selected.titleTextAttributes = @{NSForegroundColorAttributeName:kGreen100,NSParagraphStyleAttributeName : par};
        }
        
        self.tabBar.standardAppearance = appearance;
    }

你可能感兴趣的:(iOS)