我现在正在通用应用程序中工作。这里的部署目标是iOS 6.0,我正在使用Objective-C编写Xcode 6.0.1。我面临的问题是将图像放在标签栏项目上。在标签栏控制器中,我将有6或7个标签栏项目,因此默认情况下会出现“更多”按钮。需要在“更多”按钮将出现在标签栏项目中添加图像
我需要在每个标签栏项目上设置图像。
我需要帮助。
我现在正在通用应用程序中工作。这里的部署目标是iOS 6.0,我正在使用Objective-C编写Xcode 6.0.1。我面临的问题是将图像放在标签栏项目上。在标签栏控制器中,我将有6或7个标签栏项目,因此默认情况下会出现“更多”按钮。需要在“更多”按钮将出现在标签栏项目中添加图像
我需要在每个标签栏项目上设置图像。
我需要帮助。
如果标签栏控制器是您的根视图控制器,您可能可以在appdeleagte中的“didFinishLaunching ..”中执行此操作。
UITabBarController *tabBarController=(UITabBarController*) (self.window.rootViewController);
UITabBar *tabBar=tabBarController.tabBar;
UITabBarItem *tabBarItem1=[[tabBar items] objectAtIndex:0];//first tab bar
UIImage* selectedImage = [[UIImage imageNamed:@"yourImage"] imageWithRenderingMode:UIImageRenderingModeAlwaysTemplate];
[tabBarItem1 setImage:selectedImage];
添加自定义图像的TabBar
UITabBarItem *first = [[UITabBarItem alloc]initWithTitle:@"First" image:[UIImage imageNamed:@"first.png"] selectedImage:[UIImage imageNamed:@"second.png"]];
[self.tabBarController setTabBarItem:first];