2011-10-31 5 views
0

J'ai fait une application iPhone dans Xcode 4.2 et le léopard des neiges que je mets la barre de navigation et la barre d'onglets couleur de fond en mettant en œuvre le code suivantcouleur de fond TabBar dans Xcode 4.2 et ios 5

CGRect frame = CGRectMake(0.0, 0.0, self.view.bounds.size.width, 48); 
UIView *v = [[UIView alloc] initWithFrame:frame]; 
[v setBackgroundColor:[UIColor colorWithRed:1.0f/255.0f green:140.0f/255.0f  
    blue:131.0f/255.0f alpha:1.0f]]; 
    [[self.tabBarController tabBar] insertSubview:v atIndex:0]; 
[v release]; 

    self.navigationController.navigationBar.tintColor = [UIColor colorWithRed:1.0f/255.0f  
    green:125.0f/255.0f blue:131.0f/255.0f alpha:1.0f]; 

il est fonctionne bien mais maintenant si je cours cette application dans ios 5 et xcode 4.2, la couleur de la barre de navigation, mais la couleur de fond tabbar ne définit pas

Comment puis-je définir la couleur de fond de la barre d'onglets dans ios 5? Si quelqu'un sait s'il vous plaît aidez-moi.

Merci beaucoup.

+0

http://stackoverflow.com/questions/7779736/how-to-set-image-background-to-uitabbarcontroller- ios-5 –

+0

ça marche ou pas? –

+0

Yup ça marche ... merci beaucoup ... –

Répondre

2
CGRect frame = CGRectMake(0.0, 0.0, 320, 48);//Setting a Frame. 

    myTabView = [[UIView alloc] initWithFrame:frame];//Making Tab View 

    // not supported on iOS4  
    UITabBar *tabBarr = [self.tabBar tabBar]; 
    if ([tabBarr respondsToSelector:@selector(setBackgroundImage:)]) 
    { 
     // set it just for this instance 
     [tabBarr setBackgroundImage:[UIImage imageNamed:@"hot-1.png"]]; 


     // set for all 
     // [[UITabBar appearance] setBackgroundImage: ... 
    } 
    else 
    { 
     // ios 4 code here 
     //[tabBarr setBackgroundColor:c]; 
    } 

    //[myTabView setBackgroundColor:c];//Setting Color Of TaBar. 

    [myTabView setAlpha:0.8];//Setting Alpha of TabView. 

    [[self.tabBar tabBar] insertSubview:myTabView atIndex:0];//Inserting Tab As SubView. 

Utilisez ce lieu de définir la couleur à fond de TabBar ....

Questions connexes