iphone - 如何隐藏 ios 4.3 的 UITabBar 选择指示器而不是 5+?

标签 iphone ios ipad

如何隐藏 ios 4.3 的 UITabBar 选择指示器而不是 5+

我需要在 ios 4.3 中隐藏 UITabBar Controller 的选择指示器。

最佳答案

试试这段代码:

// iOS 5.0+
[self.tabBar setSelectionIndicatorImage:[[[UIImage alloc] init]autorelease]];


// for earlier versions

- (void)tabBarController:(UITabBarController *)tabBarController didSelectViewController:(UIViewController *)viewController {
    [self customizeTabBar];
}

- (void)customizeTabBar {
    NSString *imageName = [NSString stringWithFormat:@"tabBackground%i.png", tabBarCtrl.selectedIndex + 1];

    for(UIView *view in tabBarCtrl.tabBar.subviews) {  
         if([view isKindOfClass:[UIImageView class]]) {  
              [view removeFromSuperview];  
         }  
    }  
    UIImageView *background = [[[UIImageView alloc] initWithImage:[UIImage imageNamed:imageName]] autorelease];
    [tabBarCtrl.tabBar insertSubview:background atIndex:0]; 
    [tabBarCtrl.tabBar bringSubviewToFront:background];
    //if needed, here must be adding UILabels with titles, I didn't need it.
} 

希望对您有所帮助! :)

关于iphone - 如何隐藏 ios 4.3 的 UITabBar 选择指示器而不是 5+?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/10898237/

相关文章:

java - 无法从 Android 手机访问 pdf 中的链接

iphone - 将字典转换成一个数组

ios - 我可以在 iOS 处于 VoiceOver 模式时告诉它在我更改特定 UILabel 的文本时大声朗读它吗?

iphone - 数据库连接

ios - 在 iOS 中从 UIWebView/UIView 生成 PDF 的最佳方式

ios - 使用IOS中的CLLocation获取用户当前位置

javascript - 在移动 safari 中是否有使用 onbeforeunload 的替代方法?

ios - 使用 Swift 在 iOS 中读取地址簿数据

ios - 从 TabBarController 设置导航 Controller 参数

objective-c - 我可以在弹出窗口消失时触发通知吗 (iPad)