建立控制器

    // 普通控制器
GroupViewController *groupVC = [[GroupViewController alloc] init];
SecondViewController *secondVC = [[SecondViewController alloc] init];
ThirdViewController *thirdVC = [[ThirdViewController alloc] init];
FourthViewController *fourthVC = [[FourthViewController alloc] init];
    // 导航栏控制器
UINavigationController *groupNC = [[UINavigationController alloc] initWithRootViewController:groupVC];
UINavigationController *secondNC = [[UINavigationController alloc] initWithRootViewController:secondVC];
UINavigationController *thirdNC = [[UINavigationController alloc] initWithRootViewController:thirdVC];
UINavigationController *fourthNC = [[UINavigationController alloc] initWithRootViewController:fourthVC];```
@interface AppDelegate () <UITabBarControllerDelegate>
    // tabBarVC 控制器
UITabBarController *tabBarVC = [[UITabBarController alloc] init]; // 设置 tabBarVC 代理(先遵守协议)
tabBarVC.delegate = self; // 设置 tabBar 默认选中的控制器
tabBarVC.selectedIndex = 1; // 设置 tabBarVC 管理(包括)的控制器
tabBarVC.viewControllers = @[groupNC, secondNC, thirdNC, fourthNC, uiVC1, uiVC2, uiVC3];
    // 自己定义样式 tabBarItem(选中颜色)注意是那种控制器
groupNC.tabBarItem = [[UITabBarItem alloc] initWithTitle:@"活动" image:[UIImage imageNamed:@"activity"] selectedImage:[UIImage imageNamed:@"微信"]];
// 显示右上角 小圈圈
groupNC.tabBarItem.badgeValue = @"10"; secondNC.tabBarItem = [[UITabBarItem alloc] initWithTitle:@"影院" image:[UIImage imageNamed:@"cinema"] selectedImage:[UIImage imageNamed:@"通讯录"]];
thirdNC.tabBarItem = [[UITabBarItem alloc] initWithTitle:@"电影" image:[UIImage imageNamed:@"movie"] selectedImage:[UIImage imageNamed:@"发现"]];
fourthNC.tabBarItem = [[UITabBarItem alloc] initWithTitle:@"我" image:[UIImage imageNamed:@"user"] selectedImage:[UIImage imageNamed:@"我"]];
    // 设置整个 tabBar
// 颜色(和样式冲突)
tabBarVC.tabBar.barTintColor = [UIColor yellowColor];
// 样式(和颜色冲突)
// tabBarVC.tabBar.barStyle = UIBarStyleBlack;
// 字体颜色
[tabBarVC.tabBar setTintColor:[UIColor greenColor]];
#pragma mark - 选择 tabBar 所控制的控制器,会运行的方法(每次都会运行)
- (void)tabBarController:(UITabBarController *)tabBarController didSelectViewController:(UIViewController *)viewController
{
NSInteger index = [tabBarController.viewControllers indexOfObject:viewController];
if (index == 3) {
NSLog(@"four");
} if (tabBarController.selectedIndex == 2) {
NSLog(@"three");
} } #pragma mark - 控制 tabBar 能否够点击
- (BOOL)tabBarController:(UITabBarController *)tabBarController shouldSelectViewController:(UIViewController *)viewController
{
return YES;
}
    // 获取到全部的 UINavigationBar(project里面全部)
[[UINavigationBar appearance] setBarTintColor:[UIColor purpleColor]];

UI_UITabBarController的更多相关文章

随机推荐

  1. forms.ModelForm 与 forms.Form

    1. 首先 两者都是forms里的常用类. 2. 这两个类在应用上是有区别的.一般情况下,如果要将表单中的数据写入数据库或者修改某些记录的值,就要让表单类继承ModelForm; 如果提交表单后 不会 ...

  2. java把html标签字符转换成普通字符(反转换成html标签)

    package net.jasonjiang.web; import org.junit.Test; import org.springframework.web.util.HtmlUtils; /* ...

  3. JQuery实现最字体的放大缩小

    网页常常有对字体放大缩小的需求,我们不妨来看一下下面这段JQuery代码的实现. 假如在html页面代码中我们有这么一段代码: <p>啦啦啦啦啦啦啦啦啦啦</p> 那么JQue ...

  4. 使用Swing的JSpinner组件设置日期时间选择器

    代码: //获得时间日期模型 SpinnerDateModel model = new SpinnerDateModel(); //获得JSPinner对象 JSpinner year = new J ...

  5. 内核启动文件系统后第一个执行的文件(inittab启动脚本分析)

    Linux 开机脚本启动顺序: 第一步:启动内核 第二步:执行init (配置文件/etc/inittab) 第三步:启动相应的脚本,执行inittab脚本,并且执行里面的脚本/etc/init.d ...

  6. apache 监控

    当前加载模块 [root@controller01 ~]# httpd -lCompiled in modules: core.c mod_so.c http_core.c 当前版本[root@con ...

  7. ARM 中必须明白的几个概念

    文章具体介绍了关于ARM的22个常用概念. 1.ARM中一些常见英文缩写解释 MSB:最高有效位: LSB:最低有效位: AHB:先进的高性能总线: VPB:连接片内外设功能的VLSI外设总线: EM ...

  8. hdu 4403 爆搜

    题意:给一串数字,在其间加入若干加号和一个等号,问使等式成立的方案总数 if the digits serial is "1212", you can get 2 equation ...

  9. [OpenGL]纹理贴图实现 总结

    实现步骤 第一步:设置所需要的OpenGL环境 设置上下文环境 删除已经存在的渲染的缓存 设置颜色缓存 设置帧缓存 清除缓存 设置窗口大小 开启功能 编译shander 使用program 获取sha ...

  10. Syncthing vs BitTorrent Sync

    Syncthing 是一款跨平台的文件同步工具.即你在一台设备上创建.修改或删除文件,在其他设备上会同步执行相同的操作.Syncthing 不会将你的数据上传到云端,而是在你的多台设备同时在线时对指定 ...