小智 60
[[UITabBar appearance] setSelectionIndicatorImage:[[UIImage alloc] init]];
Run Code Online (Sandbox Code Playgroud)
奇迹般有效!
[[UITabBar appearance] setSelectionIndicatorImage:[UIImage {anImage}]]
Run Code Online (Sandbox Code Playgroud)
这对你使用的每个tabbar都有影响(甚至是子类的)
如果您在此处使用与标签栏背景颜色相同的图像,则不会看到指示符.
也许你甚至可以使用完全透明的图像,或者是1px*1px的图像.
如果您使用自定义图像自定义标签栏项目,您可以执行此类操作.我通过向选项卡栏添加背景图像来自定义标签栏项目,其中所有选项卡都已绘制,一个选项卡处于选定状态,其他选项卡处于未选定状态.在每个didSelectViewController中,我更改了背景图像.然后,我将背景图像视图添加到前面,并添加带有所需标题的自定义标签.
结果:我有自定义标签栏没有光泽效果.有趣的是UITabBarButtons在背景图像下,但仍然可以选择.
代码是这样的:
- (void)tabBarController:(UITabBarController *)tabBarController didSelectViewController:(UIViewController *)viewController {
[self customizeTabBar];
}
- (void)customizeTabBar {
NSString *imageName = [NSString stringWithFormat:@"tabbg%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.
}
Run Code Online (Sandbox Code Playgroud)
也许你会对此感兴趣:)
| 归档时间: |
|
| 查看次数: |
10459 次 |
| 最近记录: |