【问题标题】:Tint custom UITabBarItem为自定义 UITabBarItem 着色
【发布时间】:2013-12-30 15:24:54
【问题描述】:

在我的 iPad 应用程序中,我有自定义的 UITabBarItem 图像。我设置了选中和未选中的图标。选中的图标是红色的,未选中的图标是红色图标的轮廓,但是是灰色的。当UIModalPresentationSheet 被拉起时,应用程序的默认行为是将背景以及条形按钮项和视图染成灰色。但是,活动的标签栏项目仍然是彩色的。当我使用默认选项卡栏项目时,它会自动着色为灰色。当模态视图处于活动状态时,如何为我的自定义标签栏项目着色以匹配背景中的所有其他内容?

这是我用来使用自定义图像的方法:

appdelegate.m

- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOption {

    UITabBarController *tabBarController = (UITabBarController *)self.window.rootViewController;
    UITabBar *tabBar = tabBarController.tabBar;

    UITabBarItem *home = [tabBar.items objectAtIndex:0];

    home.selectedImage = [[UIImage imageNamed:@"home-active.png"] imageWithRenderingMode:UIImageRenderingModeAlwaysOriginal];
    home.image = [[UIImage imageNamed:@"home-inactive.png"] imageWithRenderingMode:UIImageRenderingModeAlwaysOriginal];

}

【问题讨论】:

    标签: ios objective-c cocoa-touch ios7 appdelegate


    【解决方案1】:

    我认为 UI Appearance API 能够做你需要的,并寻找本教程来定制 UITabbar

    http://www.raywenderlich.com/21703/user-interface-customization-in-ios-6

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2021-02-13
      • 2021-11-20
      • 2012-09-28
      • 2012-10-12
      • 1970-01-01
      • 2011-10-09
      • 2012-03-26
      相关资源
      最近更新 更多