我试图弄清楚如何更改选定的Tabbar图标的笔划。它通常是青色的,就像所选图标的色调。我已经更改了选定图标的色调和指示器图像,如下所示:self.tabBarController.tabBar.selectedImageTintColor = [UIColor grayColor]; self.tabBarController.tabBar.selectionIndicatorImage = [UIImage imageNamed:@"selectedTab.png"];
但现在我仍然在图标周围画了这个青色的笔画
Image
有人知道它的代码吗,因为我找不到它
发布于 2012-06-16 20:48:00
我以前也注意到了这一点。我最终只是手动设置了选中和未选中的图像,而不是让它为我渲染颜色。
然后,您可以使用Photoshop或您最喜欢的图像编辑软件为每个选项卡设计两个图像。一个图像将是选项卡图标,当选项卡被选中时,另一个图像将是选项卡未被选中时的图标。您将需要在Photoshop中自己应用色调颜色。
将所有图像导入Xcode后,可以在所需的UITabBarItem上设置它们。我通常在我的视图控制器初始化函数中设置它们。
- (id)initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil
{
self = [super initWithNibName:nibNameOrNil bundle:nibBundleOrNil];
if (self) {
[self.tabBarItem setFinishedSelectedImage:[UIImage imageNamed:@"my-selected-icon"] withFinishedUnselectedImage:[UIImage imageNamed:@"my-deselected-icon"]];
}
return self;
}您必须对选项卡栏上的每个视图控制器执行此操作。
发布于 2012-12-18 05:55:53
尝试以下代码,将其放入viewDidLoad中:
for (UITabBarItem * barItem in theTabBar.items) {
UIImage * image = barItem.image;
[barItem setFinishedSelectedImage:image withFinishedUnselectedImage:image];
}https://stackoverflow.com/questions/11063319
复制相似问题