iOS 解决UITabBarItem选中图片默认为蓝色的方法

在开发中我们有两张图片,在tabBarItem切换时,他没有和我们切的图片颜色一致,而是默认的显示蓝色,解决该类问题方法。

 HomeViewController *homeVC = [[HomeViewController alloc] init];
    homeVC.title = @"主页";
    UINavigationController *homeNaVC = [[UINavigationController alloc] initWithRootViewController:homeVC];
    UIImage * homeImage = [UIImage imageNamed:@"shouye"];
    homeImage = [homeImage  imageWithRenderingMode:UIImageRenderingModeAlwaysOriginal];
    UIImage * homeSelectImge = [UIImage imageNamed:@"shouyeSelect"];
    homeSelectImge = [homeSelectImge imageWithRenderingMode:UIImageRenderingModeAlwaysOriginal];
    UITabBarItem * homeItem = [[UITabBarItem alloc]initWithTitle:@"首页" image:homeImage selectedImage:homeSelectImge];

 //改变tabBarItem字体的颜色
    [homeItem setTitleTextAttributes:[NSDictionary dictionaryWithObjectsAndKeys:[UIColor redColor],NSForegroundColorAttributeName, nil] forState:UIControlStateSelected];

效果图如下:

更多文章:http://blog.csdn.net/qq_29284809

你可能感兴趣的:(ios,开发,图片,导航栏图片)