如何在选定的UITabBar项目之上有覆盖层?

任何人都知道如何有一个额外的覆盖在选定的项目之上?

背景是在应用程序委托中完成的。

UIImageView *imageView = [[UIImageView alloc] initWithImage:[UIImage imageNamed:@"navbar_bgrd.png"]]; if ([[[UIDevice currentDevice] systemVersion] floatValue] > 4.9) { //iOS 5 [self.tabBarController.tabBar insertSubview:imageView atIndex:1]; } else { //iOS 4.whatever and below [self.tabBarController.tabBar insertSubview:imageView atIndex:0]; } 

在这里输入图像说明

未选中的

在这里输入图像说明

固定IOS 5,UIappearancefunction

  //set the background of tab bar UIImageView *imageView = [[UIImageView alloc] initWithImage:[UIImage imageNamed:@"navbar_bgrd.png"]]; if ([[[UIDevice currentDevice] systemVersion] floatValue] > 4.9) { //iOS 5 //[self.tabBarController.tabBar insertSubview:imageView atIndex:1]; [[UITabBar appearance] setBackgroundImage:[UIImage imageNamed:@"navbar_bgrd.png"]]; [[UITabBar appearance] setSelectionIndicatorImage: [UIImage imageNamed:@"navbaractive.png"]]; [[UITabBarItem appearance] setTitleTextAttributes: [NSDictionary dictionaryWithObjectsAndKeys: [UIColor colorWithRed:75.0/255.0 green:75.0/255.0 blue:75.0/255.0 alpha:1.0], UITextAttributeTextColor, [UIColor clearColor], UITextAttributeTextShadowColor, [NSValue valueWithUIOffset:UIOffsetMake(0, 1)], UITextAttributeTextShadowOffset, nil] forState:UIControlStateNormal]; [[UITabBarItem appearance] setTitleTextAttributes: [NSDictionary dictionaryWithObjectsAndKeys: [UIColor whiteColor], UITextAttributeTextColor, [UIColor clearColor], UITextAttributeTextShadowColor, [NSValue valueWithUIOffset:UIOffsetMake(0, 1)], UITextAttributeTextShadowOffset, nil] forState:UIControlStateSelected];