我目前正在我正在构建的应用中实现自定义标签栏,我遇到了一些麻烦。选中此选项卡时,我仍会在左侧看到白线,选择右侧选项卡时,我也会在右侧看到白线。其他标签似乎也不正确。我正在使用iPhone 4模拟器。
菜单图像为640x108px(在此处使用@ 2x文件名) 图标为64x50 选择器背景为122x100(在此处使用@ 2x文件名)
除此之外,我还想在突出显示中间选项卡时更改选择器图像。那可能吗?我在这里有一个挖掘,似乎无法找到一个有效的解决方案。
我正在AppDelegate.m中实现我的标签栏控制器,如下所示:
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions: (NSDictionary *)launchOptions
{
// Override point for customization after application launch.
//create new tab bar appearance
UITabBar *tabBar = [UITabBar appearance];
//set background image
[tabBar setBackgroundImage:[UIImage imageNamed:@"menu.png"]];
//create a colour and apply it as tint colour when items aren't selected.
UIColor *color=[UIColor colorWithRed:64.0/255.0 green:147.0/255.0 blue:52.0/255.0 alpha:255.0];
UIColor *colorSelected=[UIColor colorWithRed:1.0 green:1.0 blue:1.0 alpha:1.0];
[tabBar setTintColor:color];
[tabBar setSelectedImageTintColor:colorSelected];
int numberOfTabs = 5;
[tabBar setSelectionIndicatorImage:[UIImage imageNamed:@"selected.png"]];
return YES;
}
修改
有关详细信息,请参阅下图
Image of current tab bar in simulator http://stephenbiggerstaff.net/img/tabbar.png