【发布时间】:2023-04-02 12:35:01
【问题描述】:
我创建了一个tabBar 并在其中设置了图像,但它在tabBarItem 下方留下了太多空间。我怎样才能删除它?
这是我的tabBar,而不是现在显示
我想这样显示
显示标签栏
firstVC = [[FirstViewController alloc] initWithNibName:@"FirstViewController" bundle:nil];
secondVC = [[SecondViewController alloc] initWithNibName:@"SecondViewController" bundle:nil];
thirdVC = [[ThirdViewController alloc] initWithNibName:@"ThirdViewController" bundle:nil];
forthVC = [[ForthViewController alloc] initWithNibName:@"ForthViewController" bundle:nil];
[[UITabBar appearance] setTintColor:[UIColor whiteColor]];
NSArray *viewControllersArray = [[NSArray alloc] initWithObjects:firstVC,secondVC,thirdVC,forthVC, nil];
self.tabController = [[UITabBarController alloc] init];
[self.tabController setViewControllers:viewControllersArray animated:NO];
[self.window addSubview:self.tabController.view];
//self.tabController.selectedIndex = 1;
self.tabController.delegate = self;
self.window.rootViewController = self.tabController;
[self.window makeKeyAndVisible];
对于 tabBar 背景图片我使用了这个代码
UIImage* tabBarBackground = [UIImage imageNamed:@"tabbarimg1.png"];
[[UITabBar appearance] setBackgroundImage:tabBarBackground];
为了在项目上设置图像,我使用了这个代码
//used to set the tabBarItem images
[self.tabBarItem setFinishedSelectedImage:[UIImage imageNamed:@"home_tab"] withFinishedUnselectedImage:[UIImage imageNamed:@"home_tab"]];
//Set the badge on tabBarItem
[self.tabBarItem setBadgeValue:@"15"];
【问题讨论】:
-
你的标签栏在哪里?正如您所写的“这是我的标签栏,而不是现在显示”
-
是否有问题,因为我添加了我的图片,它显示了一些其他图像,如 GTA 副城图像......奇怪......
-
嘿@Kane 不要显示你的标签栏......
-
@Will 现在完成检查现在仍然不明白当我第一次添加这张图片时出现什么问题,当时我的第一张图片显示了一些多面性的人,他们发表演讲,第二张图片显示 Vicecity 而不是我的图片所以我必须删除图像并重新插入它..
-
@BhaveshNai 现在检查...
标签: iphone ios tabbar uitabbaritem