去掉TabBar蓝色,还原图片原本颜色的方法

-(UITabBarItem *) createTabBarItemWithTitle:(NSString*)title image:(NSString*)imageName selectedImage:(NSString*)selectedImageName
{
    UITabBarItem *tabBarItem = [[UITabBarItem alloc] init];
    UIImage *unselectedImage = [UIImage imageNamed:imageName];
    UIImage *selectedImage = [UIImage imageNamed:selectedImageName];
    
    tabBarItem.image =[unselectedImage imageWithRenderingMode:UIImageRenderingModeAlwaysOriginal];
    tabBarItem.selectedImage =[selectedImage imageWithRenderingMode:UIImageRenderingModeAlwaysOriginal];
    
    if (title != nil)
    {
        tabBarItem.title = title;
    }
    
    return tabBarItem;
}

   [[UITabBarItem appearance] setTitleTextAttributes:[NSDictionary dictionaryWithObjectsAndKeys:
                                                       [UIColor grayColor], NSForegroundColorAttributeName,
                                                       nil] forState:UIControlStateSelected];

你可能感兴趣的:(tab)