0

我正在开发一个需要自定义的应用程序,tabbar如下Image所示。在我想要的Image家居tabbar项目展示中,我尝试了但我无法更改突出显示的区域,如第一个Image所示,我得到的结果如第二个所示Image。所以我想首先得到它,Image我需要tabbar像在主页按钮中一样裁剪整个项目图像还是需要更改所选区域的颜色?第一张图片

第二张图片

提前感谢您的指导。

4

2 回答 2

1

尝试这个,

didFinishLaunchingWithOptions

    UIImage *selectedImage0 = [UIImage imageNamed:@"home_sel.png"];
    UIImage *unselectedImage0 = [UIImage imageNamed:@"home.png"];

    UIImage *selectedImage1 = [UIImage imageNamed:@"weight_sel.png"];
    UIImage *unselectedImage1 = [UIImage imageNamed:@"weight1.png"];

    UIImage *selectedImage2 = [UIImage imageNamed:@"rewards_sel.png"];
    UIImage *unselectedImage2 = [UIImage imageNamed:@"rewards.png"];

    UIImage *selectedImage3 = [UIImage imageNamed:@"menu_sel.png"];
    UIImage *unselectedImage3 = [UIImage imageNamed:@"menu.png"];

    UIImage *selectedImage4 = [UIImage imageNamed:@"shop_sel.png"];
    UIImage *unselectedImage4 = [UIImage imageNamed:@"shop.png"];

    UIImage *selectedImage5 = [UIImage imageNamed:@"account_sel.png"];
    UIImage *unselectedImage5 = [UIImage imageNamed:@"account.png"];

    UITabBar *tabBar = tabBarController.tabBar;

    UITabBarItem *item0 = [tabBar.items objectAtIndex:0];
    UITabBarItem *item1 = [tabBar.items objectAtIndex:1];
    UITabBarItem *item2 = [tabBar.items objectAtIndex:2];
    UITabBarItem *item3 = [tabBar.items objectAtIndex:3];
    UITabBarItem *item4 = [tabBar.items objectAtIndex:4];
    UITabBarItem *item5 = [tabBar.items objectAtIndex:5];

    [item0 setFinishedSelectedImage:selectedImage0 withFinishedUnselectedImage:unselectedImage0];
    [item1 setFinishedSelectedImage:selectedImage1 withFinishedUnselectedImage:unselectedImage1];
    [item2 setFinishedSelectedImage:selectedImage2 withFinishedUnselectedImage:unselectedImage2];
    [item3 setFinishedSelectedImage:selectedImage3 withFinishedUnselectedImage:unselectedImage3];
    [item4 setFinishedSelectedImage:selectedImage4 withFinishedUnselectedImage:unselectedImage4];
    [item5 setFinishedSelectedImage:selectedImage5 withFinishedUnselectedImage:unselectedImage5];

window.rootViewController=tabBarController;
于 2013-05-21T09:35:39.047 回答
0

在 iOS 6 中,您现在可以使用 UIAppearance 来设置标签栏和许多其他 iOS UI 的样式。

将以下代码添加到您的 AppDelegate:

    [[UITabBar appearance] setBackgroundImage:[[UIImage imageNamed:@"MY_TABS_BACKGROUND"]
    resizableImageWithCapInsets:UIEdgeInsetsMake(0, 0, 0, 0)]];  
    [[UITabBar appearance] setSelectionIndicatorImage:[UIImage imageNamed:@"MY_SELECTION_IMAGE"]];

查看以下教程以获得更好的想法并查看示例项目 http://www.raywenderlich.com/21703/user-interface-customization-in-ios-6

BooRanger

于 2013-05-21T08:56:16.030 回答