Um using my own TabBarController
which is ElWafyatTabBarController
basically it inherits from UITabBarController
.
In ElWafyatTabBarController.m -> viewDidLoad
I've created some ViewControllers
, Then I created UINavigationController
's with rootViewController to the viewControllers
I've made in the step before.
then I've created UITabBarItem
and set it with image and title for each navigation controller which has rootViewController
to the viewControllers that I've created in the first step, and set the tabBarItem
for these navigationController
to these tabBarItem
.
The problem I found is even the title for the UITabBarItem
is shown correctly, but the image is displayed at blue Color.
FYI: I've created two images named test.png and test@2x.png with dimensions 32x32 and 64x64 and I still have these issue, So any one can help ?
this is my Code:
ElWafyatTabBarController -> viewDidLoad
- (void)viewDidLoad
{
[super viewDidLoad];
HomeViewController *homeViewController = [[HomeViewController alloc]
initWithNibName:@"HomeViewController" bundle:nil];
NaaiViewController *naaiViewController = [[NaaiViewController alloc]
initWithNibName:@"NaaiViewController" bundle:nil];
MushatraViewController *mushatraViewController = [[MushatraViewController alloc]
initWithNibName:@"MushatraViewController" bundle:nil];
TakremViewController *takremViewController = [[TakremViewController alloc]
initWithNibName:@"TakremViewController" bundle:nil]
UINavigationController *homeNavC = [[UINavigationController alloc]initWithRootViewController:homeViewController];
UINavigationController *naaiNavC = [[UINavigationController alloc]initWithRootViewController:naaiViewController];
UINavigationController *mushatraNavC = [[UINavigationController alloc]initWithRootViewController:mushatraViewController];
UINavigationController *takremNavC = [[UINavigationController alloc]initWithRootViewController:takremViewController];
// Setup Controllers for Tab Bar. (first level).
// [homeNavC.tabBarItem setTitle:@"الرئيسية"];
// [naaiNavC.tabBarItem setTitle:@"نعي"];
// [mushatraNavC.tabBarItem setTitle:@"مشاطرة"];
// [takremNavC.tabBarItem setTitle:@"تكريم"];
homeNavC.navigationBar.titleTextAttributes = [NSDictionary dictionaryWithObject:[UIColor whiteColor] forKey:UITextAttributeTextColor];
naaiNavC.navigationBar.titleTextAttributes = [NSDictionary dictionaryWithObject:[UIColor whiteColor] forKey:UITextAttributeTextColor];
mushatraNavC.navigationBar.titleTextAttributes = [NSDictionary dictionaryWithObject:[UIColor whiteColor] forKey:UITextAttributeTextColor];
takremNavC.navigationBar.titleTextAttributes = [NSDictionary dictionaryWithObject:[UIColor whiteColor] forKey:UITextAttributeTextColor];
homeNavC.navigationBar.barStyle = UIBarStyleBlack;
naaiNavC.navigationBar.barStyle = UIBarStyleBlack;
mushatraNavC.navigationBar.barStyle = UIBarStyleBlack;
takremNavC.navigationBar.barStyle = UIBarStyleBlack;
UITabBarItem* tabBarItem = [[UITabBarItem alloc] initWithTitle:@"Colors" image:[UIImage imageNamed:@"test.png"] tag:9];
homeNavC.tabBarItem = tabBarItem;
myViewControllers = [ NSArray arrayWithObjects:takremNavC, mushatraNavC, naaiNavC, homeNavC,nil];
[self setViewControllers:myViewControllers animated:YES];
[self.tabBarController setSelectedIndex:3];
[self setSelectedIndex:3];
}
and these the output: