ios tabbar customization with images

前端 未结 3 1752
说谎
说谎 2021-01-16 05:31

i\'m working in ios application i need to customize tabbar to be like this

First I created 5 viewcontrollers each one in navi

3条回答
  •  栀梦
    栀梦 (楼主)
    2021-01-16 06:18

    For customizing tab bar in ios4 is not available with code for that you need to make us custom tab bar for that you can refer this Que.

    How to Customize the tabbarcontroller

    or you also can do like simple logic with making full tab bar image like this enter image description here

    here i have made one image view on appdel did finish method and done like this in the app.

    self.imgV.frame=CGRectMake(0, 431, 320, 49);
    [self.tabbarcontroller.view addSubview:self.imgV];
    
    - (BOOL)tabBarController:(UITabBarController *)tabBarController shouldSelectViewController:(UIViewController *)viewController{
        NSUInteger index=[[tabBarController viewControllers] indexOfObject:viewController];
        NSString *deviceType = [UIDevice currentDevice].model;
        NSLog(@"Device%@",deviceType);
    
        if(UI_USER_INTERFACE_IDIOM()==UIUserInterfaceIdiomPad){
          //  self.imgV.frame=CGRectMake(0, 975, 768, 49);
            //[self.tabbarcontroller.view addSubview:self.imgV];
    
            switch (index) {
                case 0:
                    self.imgV.image=[UIImage imageNamed:@"reservation_tab~iPad.png"];
                    break;
                case 1:
                    self.imgV.image=[UIImage imageNamed:@"place_order_tab~iPad.png"];
                    break;
                case 2:
                    self.imgV.image=[UIImage imageNamed:@"location_tab~iPad.png"];
                    break;
                case 3:
                    self.imgV.image=[UIImage imageNamed:@"favorite_tab~iPad.png"];
                    break;
                case 4:
    
                    self.imgV.image=[UIImage imageNamed:@"signature_dishes_tab~iPad.png"];
    
                    break;
                case 5:
                    self.imgV.image=[UIImage imageNamed:@"history_tab~iPad.png"];
                    break;
                case 6:
    
                    self.imgV.image=[UIImage imageNamed:@"contact_us_tab~iPad.png"];
    
                    break;
                default:
                    break;
            }
    
        }
        else{
    
    
    
        switch (index) {
            case 0:
                self.imgV.image=[UIImage imageNamed:@"reservation_tab.png"];
                break;
            case 1:
                self.imgV.image=[UIImage imageNamed:@"place_order_tab.png"];
                break;
            case 2:
                self.imgV.image=[UIImage imageNamed:@"location_tab.png"];
                break;
            case 3:
                self.imgV.image=[UIImage imageNamed:@"favorite_tab.png"];
                break;
            case 4:
    
                           self.imgV.image=[UIImage imageNamed:@"gallery_tab.png"];
    
                break;
            default:
                break;
        }
        }
        return YES;
    }
    

提交回复
热议问题