【发布时间】: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