iOS自定义标签栏 [英] iOS custom tabbar

查看:114
本文介绍了iOS自定义标签栏的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

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

I just started with iOS development and am just playing around atm.

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

I'm trying to transform the default tabbar buttons into something more custom.

经过一番环顾,我发现你可以为每个按钮创建自定义状态,所以我做了:

After some looking around I found you can create custom states for every button, so I did:

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

然而,我无法摆脱默认按钮,它会改变图像,但它不会不要改变我的整个按钮。

However, I can't get rid of the default button, it changes the image, but it doesn't change my entire button.

我还需要做些什么吗?

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


推荐答案

检查以下链接(大部分定制的标签栏控制器)

Check the following Links(Most of the customization of the tab-bar controller)


  1. 实现自定义标签栏

  2. 带自定义颜色的标签栏

  3. 自定义Tabbar diff。背景

  4. 如何保存用户自定义Tab键顺序]

  5. RX -Tabbar controller

  1. Implement a Custom Tab Bar
  2. Tabbar with custom colors
  3. Custom Tabbar diff. background
  4. How to Save User Customized Tab Order]
  5. RX -Tabbar controller

这篇关于iOS自定义标签栏的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆