iOS 13 TabBar的字体颜色及背景颜色的设置

iOS13之前修改的方法

//未选中颜色

    NSDictionary * noselectedTitleColordic =@{NSForegroundColorAttributeName:[UIColor colorWithHexString:@"#666666"]};

    [[UITabBarItem appearance] setTitleTextAttributes:noselectedTitleColordic forState:UIControlStateNormal];

    //选中颜色

    NSDictionary * selectedTitleColordic =@{NSForegroundColorAttributeName:[UIColor colorWithHexString:@"#24C678"]};

    [[UITabBarItem appearance] setTitleTextAttributes:selectedTitleColordic forState:UIControlStateSelected];

 

iOS13 之后的方法

UITabBarAppearance *appearance = [UITabBarAppearance new];

            UIImage *bgImage = [UIImage imageNamed:@"home_line"];

      [appearance setShadowImage:bgImage];

      [appearance setBackgroundImage:[UIImage qmui_imageWithColor:[UIColor whiteColor]]];

      appearance.stackedLayoutAppearance.selected.titleTextAttributes = @{NSForegroundColorAttributeName:Repair_green};

      board.tabBarItem.standardAppearance = appearance;

你可能感兴趣的:(iOS)