我刚开始使用iOS开发,我只是在玩atm。iOS自定义标签栏
我想将默认的tabbar按钮转换为更自定义的东西。
后一些环顾四周,我发现你可以为每个按钮创建自定义的状态,所以我所做的:
UIImage *selectedImage0 = [UIImage imageNamed:@"first.png"];
UIImage *unselectedImage0 = [UIImage imageNamed:@"second.png"];
UITabBar *tabBar = self.tabBarController.tabBar;
UITabBarItem *item0 = [tabBar.items objectAtIndex:0];
[item0 setFinishedSelectedImage:selectedImage0 withFinishedUnselectedImage:unselectedImage0];
但是,我无法摆脱的默认按钮,它改变了形象,但它不会改变我的整个按钮。
有什么我需要做的吗?
UIViewController *viewController1 = [[FirstViewController alloc] initWithNibName:@"FirstViewController" bundle:nil];
UIViewController *viewController2 = [[SecondViewController alloc] initWithNibName:@"SecondViewController" bundle:nil];
self.tabBarController = [[UITabBarController alloc] init];
self.tabBarController.viewControllers = [NSArray arrayWithObjects:viewController1, viewController2, nil];
self.window.rootViewController = self.tabBarController;
[self.window makeKeyAndVisible];
UIImage *selectedImage0 = [UIImage imageNamed:@"first.png"];
UIImage *unselectedImage0 = [UIImage imageNamed:@"second.png"];
UITabBar *tabBar = self.tabBarController.tabBar;
UITabBarItem *item0 = [tabBar.items objectAtIndex:0];
[item0 setFinishedSelectedImage:selectedImage0 withFinishedUnselectedImage:unselectedImage0];
http://stackoverflow.com/questions/4710298/how-can-i-create-custom-tab-bar-add-custom-images-in-tab-bar-without-xib-cha...Visit这个堆栈帖子.. – Nit 2012-04-27 05:59:04
请参阅本教程和自定义选项卡栏的源代码。 [Custom tabbar](http://cocoacontrols.com/search?utf8=%E2%9C%93&q=tabbar) – 2012-04-27 06:13:06
[This answer](http://stackoverflow.com/questions/41139914/how-to-make- multiple-color-tab-bar-in-swift-3/41140329#41140329)可能会有用。 – 2016-12-14 12:24:12