1

Hi i am developing in Custom tabbar and my deployment Target is iOS4

enter image description here

In iOS5 wise Everything fine.

In iOS4 wise not working

Code snippet

UIImageView *imageView = [[UIImageView alloc] initWithImage:[UIImage imageNamed:@"tabBack.png"]];

if ([[[UIDevice currentDevice] systemVersion] floatValue] > 4.9) {
    //iOS 5
    [self.tabBarController.tabBar insertSubview:imageView atIndex:1];
   self.tabBarController.tabBar.selectionIndicatorImage =[UIImage     imageNamed:@"red_Back.png"];
    [[UITabBar appearance] setSelectedImageTintColor:[UIColor whiteColor]];

}
else {
    //iOS 4
    [self.tabBarController.tabBar insertSubview:imageView atIndex:0];
}

Iam tried some codes

1) Is there a way to use a custom selected image for UITabBarItem?

2) Really cool way to create custom UITabBar for iPhone app?

no effect to those code samples

I tried a lot,any way to do this task in iOS4 ?

Any shortcut?

Any tutorial or example pls

Thanks in Advance

Community
  • 1
  • 1
Senthil
  • 510
  • 12
  • 28

1 Answers1

0

Initially Check the Screen size

- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {

    NSInteger tabbarHeight;
    CGRect Bounds = [[UIScreen mainScreen] bounds];
    if (Bounds.size.height == 568) {
        // code for 4-inch screen
        tabbarHeight = 519;
              } else {
        // code for 3.5-inch screen
        tabbarHeight = 431;
     }


    UITabBarController *tabBarController = [[UITabBarController alloc]init];
    tabBarController.selectedIndex=0;
    tabBarController.delegate=self;
    img = [[UIImageView alloc]init];
    img.image=[UIImage imageNamed:@"Tabimage.png"];
    img.frame=CGRectMake(0,tabbarHeight, 320, 49);         
    [self.tabBarController.view addSubview:img];    
    tabBarController.viewControllers = @[homeNavigationController,profileNavigationControler,notificationNavigationController,newsNavigationController,aboutUsNavigationController];
     self.window.rootViewController = self.tabBarController;    
    [self.window makeKeyAndVisible];
    return YES;
 }

- (BOOL)tabBarController:(UITabBarController *)tabBarController shouldSelectViewController:(UIViewController *)viewController{
    NSUInteger index=[[tabBarController viewControllers] indexOfObject:viewController];
    switch (index) {
        case 0:
            self.img.image=[UIImage imageNamed:@"Tabone.png"];
            break;
        case 1:
            self.img.image=[UIImage imageNamed:@"Tabtwo.png"];
            break;
        case 2:
            self.img.image=[UIImage imageNamed:@"Tabthree.png"];
            break;
        case 3:
            self.img.image=[UIImage imageNamed:@"Tabfour.png"];
            break;
        case 4:
            self.img.image=[UIImage imageNamed:@"Tabfive.png"];
            break;
        default:
            break;
    }
    return YES;
 }
Senthil
  • 510
  • 12
  • 28