私のアプリにはUITabBarがあります。そのタブバーアイテムの選択スタイル、つまり光沢のある効果を非表示/削除したいのですが、プログラムで実行できますか?..プログラムでタブバーアイテムを配置する方法もあります。
1 に答える
0
このコードを試してみてください.....
// 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.
}
于 2012-11-05T10:33:40.083 に答える