【问题标题】:iphone - tabbar set imagetintcolor (offstate)iphone - 标签栏设置图像色调颜色(状态)
【发布时间】:2012-06-02 13:47:16
【问题描述】:

我看到[tabBar setSelectedImageTintColor:[UIColor]] 很棒,但是我如何设置 offstate 的 imagetintcolor?我似乎找不到[tabBar setImageTintColor][tabBar setUnSelectedImageTintColor]

【问题讨论】:

    标签: iphone objective-c tabbar


    【解决方案1】:

    查看UITabBarItem 文档的“管理完成和选定的图像”任务部分。

    【讨论】:

    • 这并没有解决图像着色的问题。
    • selectedImageTintColor 的文档清楚地说:If you want to also customize the unselected image appearance, you must sent setFinishedSelectedImage:withFinishedUnselectedImage: to individual tab bar items.
    • 完美!这还有一个好处是可以帮助我删除出现在图标上的讨厌的默认渐变!
    • 注意:“在 iOS 7.0 中已弃用。将 image 和 selectedImage 与 UIImageRenderingModeAlwaysOriginal 一起使用。”
    【解决方案2】:

    对于快速剪切和粘贴:

    NSArray *tabBarImages = [[NSArray alloc] initWithObjects:@"tab_a.png",
                             @"tab_b.png",
                             @"tab_c.png",
                             @"tab_d.png",
                             @"tab_e.png",
                             nil];
    
    
    for (uint i=0;i<[_tabBarController.tabBar.items count];i++)
    {
        UITabBarItem *uitbi = [_tabBarController.tabBar.items objectAtIndex:i];
    
        NSString *imageRef = [tabBarImages objectAtIndex:i];
        [uitbi setFinishedSelectedImage:[UIImage imageNamed:imageRef] withFinishedUnselectedImage:[UIImage imageNamed:imageRef]];
    
    }
    

    【讨论】:

      【解决方案3】:

      为了将按钮的外观和感觉更改为详细程度,您将必须实现自己的自定义 UITabBar。这是一个很好的参考:

      http://idevrecipes.com/2010/12/16/raised-center-tab-bar-button/

      【讨论】:

      • 只改变标签栏的背景颜色而不改变标签栏的图像。
      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2014-11-06
      • 2015-07-11
      • 1970-01-01
      • 2015-07-16
      相关资源
      最近更新 更多