0

我目前正在我正在构建的应用程序中实现自定义标签栏,但遇到了一些麻烦。I still see a white line on the left hand side when this tab is selected and also on the right when the right tab is selected. 其他选项卡似乎也不完全正确。我正在为此使用 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;
}

编辑:

有关更多详细信息,请参见下图

模拟器中当前标签栏的图像
(来源:stephenbigerstaff.net

4

0 回答 0