iOS 自定义标签栏

标签 ios uitabbarcontroller

我刚开始 iOS 开发,只是在玩 atm。

我正在尝试将默认的标签栏按钮转换为更自定义的内容。

环顾四周后,我发现您可以为每个按钮创建自定义状态,所以我这样做了:

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];

最佳答案

关于iOS 自定义标签栏,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/10345426/

相关文章:

ios - iPhone 通知中的旧消息未删除尝试

ios - Google Places API 违规

ios - 从标签栏 Controller 注销到 Root View Controller

ios - Swift 设置子类 UIButton ButtonType

ios - 仅更改图标和标题是否足以将新版本的应用程序放入应用程序商店?

ios - Swift 泛型中的文字

ios - 标签栏内的 UISplitViewController

ios - iOS 中键盘和 UIView 之间的空白区域

ios - UITabBarVC 内的 UISplitViewController : showDetail and hide tab bar

ios - 如何在 Swift 编程中获得基于导航的模板功能