// 计入导航控制器时,要使得底部的TabBar消消失

test.hidesBottomBarWhenPushed = YES;

/**

*  布局子控件

*/

- (void)layoutSubviews

{

[super layoutSubviews];

// NSClassFromString(@"UITabBarButton") == [UITabBarButton class]

// NSClassFromString(@"UIButton") == [UIButton class]

/**** 设置所有UITabBarButton的frame ****/

// 按钮的尺寸

CGFloat buttonW = self.frame.size.width / 5;

CGFloat buttonH = self.frame.size.height;

CGFloat buttonY = 0;

// 按钮索引

int buttonIndex = 0;

for (UIView *subview in self.subviews) {

// 过滤掉非UITabBarButton

//  if (![@"UITabBarButton" isEqualToString:NSStringFromClass(subview.class)]) continue;

if (subview.class != NSClassFromString(@"UITabBarButton")) continue;

// 设置frame

CGFloat buttonX = buttonIndex * buttonW;

if (buttonIndex >= 2) { // 右边的2个UITabBarButton

buttonX += buttonW;

}

subview.frame = CGRectMake(buttonX, buttonY, buttonW, buttonH);

// 增加索引

buttonIndex++;

}

/**** 设置中间的发布按钮的frame ****/

self.publishButton.frame = CGRectMake(0, 0, buttonW, buttonH);

self.publishButton.center = CGPointMake(self.frame.size.width * 0.5, self.frame.size.height * 0.5);

}

/////////////////////////////

// 修改控件的外观颜色

[UISwitch appearance].onTintColor = [UIColor orangeColor];

/*设置TabBarViewController控制器的颜色*/

/** 文字属性 **/

// 普通状态下的文字属性

NSMutableDictionary *normalAttrs = [NSMutableDictionary dictionary];

normalAttrs[NSFontAttributeName] = [UIFont systemFontOfSize:20];

normalAttrs[NSForegroundColorAttributeName] = [UIColor redColor];

// 选中状态下的文字属性

NSMutableDictionary *selectedAttrs = [NSMutableDictionary dictionary];

selectedAttrs[NSForegroundColorAttributeName] = [UIColor greenColor];

// 创建窗口

self.window = [[UIWindow alloc] init];

self.window.frame = [UIScreen mainScreen].bounds;

// 设置根控制器

UITabBarController *tabBarVc = [[UITabBarController alloc] init];

UITableViewController *vc0 = [[UITableViewController alloc] init];

vc0.view.backgroundColor = [UIColor redColor];

vc0.tabBarItem.title = @"精华";

[vc0.tabBarItem setTitleTextAttributes:normalAttrs forState:UIControlStateNormal];

[vc0.tabBarItem setTitleTextAttributes:selectedAttrs forState:UIControlStateSelected];

vc0.tabBarItem.image = [UIImage imageNamed:@"tabBar_essence_icon"];

vc0.tabBarItem.selectedImage = [UIImage imageNamed:@"tabBar_essence_click_icon"];

[tabBarVc addChildViewController:vc0];

有关TabBar的一些性质的更多相关文章

  1. uniapp-vuex实现tabbar提示点

    底部入口栏的红点提示是app中常见的功能,或者说是必要功能,通常用来提醒用户去查看或操作某个模块内容. 看项目性质如果需要比较多并且灵活的提示,则需要用到长连接技术. 1.红点提示是根据接口返回的数据 ...

  2. B样条基函数的定义和性质

    定义:令U={u0,u1,…,um}是一个单调不减的实数序列,即ui≤ui+1,i=0,1,…,m-1.其中,ui称为节点,U称为节点矢量,用Ni,p(u)表示第i个p次(p+1阶)B样条基函数,其定 ...

  3. 自定义tabBar

    ★★★★自定义tabBar★★★★★★★ Demo下载地址:https://github.com/marlonxlj/tabBarCustom.git 前言: 有的时候需求要对tabBar进行自定义的 ...

  4. react-native的tabbar和navigator混合使用

    前段时间搭建项目使用了navigator和react-native-tab-navigator,现在我教大家搭建一个通用的简单框架. 先把几张图贴在这里,这就是我们今天要搭建的东西,别看页面简单,但是 ...

  5. iOS 切换首页-更改tabbar的容器控制器

    最近想到的一个小需求: 首页切换:点击一个切换按钮,能实现首页的风格.排版等变换,原理是用一个新的VC替换掉. 效果如下:   ====>====> 实现方式很简单: 以我的Demo为例, ...

  6. weui tabbar 切换

    Html: <!DOCTYPE html> <html> <head> <meta charset="UTF-8"> <met ...

  7. 悬浮TabBar的实现--此段代码来自网络

    悬浮TabBar的实现 这个TabBar看着像是用自定义TabBar做的,但事实上它还是用的系统的TabBar,给系统的tabBar.backgroundImage设置一张设计好的背景图片. TabB ...

  8. 项目中 -- 设置tabBar样式 (旅游局)

    - (void)addChildViewController:(UIViewController *)ViewController image:(UIImage *)image selectImg:( ...

  9. iOS 有TabBar的VC界面push后隐藏TabBar的方法

    当一个UITabbarController管理多个UINavigationController的时候, 我们要从这每一个UINavigationController中push一个ViewControl ...

随机推荐

  1. (转)iOS安全 对本地文件的保护

    开篇先扯几句题外话,许多朋友都问我怎么不写防啊,我确实有点犹豫.hackers总是想象如果自己是开发者会怎么写,然后才能找到入手点.同理,开发者们也要想象自己是hackers会怎么做,才能采取相应的防 ...

  2. Photoshop的评价

    Photoshop是Adobe公司旗下最为出名的图像处理软件之一. Photoshop的功能性:主要处理以像素所构成的数字图象.使用其众多的编修与绘图工具,可以有效地进行图片编辑工作.支持Window ...

  3. win32自绘按钮,使用GDI+(三)

    解决前面的问题.实现鼠标移动进入到按钮的特效. 效果是这样的 鼠标移到按钮上,改变按钮的颜色(这里用的是直接换贴在按钮上的图片) 程序运行 鼠标进入按钮 代码 #ifndef ULONG_PTR // ...

  4. 在 Windows 下部署 Vagrant

    Vagrant 是一个可创建轻便.可复用的虚拟开发环境的跨平台工具,通过打包分可使所有开发成员使用统一的开发环境. 下面是我自己记录配置 Vagrant 的过程. 1.安装 VirtualBox 略. ...

  5. OGRE启动过程详解(OGRE HelloWorld程序原理解析)

    本文介绍 OGRE 3D 1.9 程序的启动过程,即从程序启动到3D图形呈现,背后有哪些OGRE相关的代码被执行.会涉及的OGRE类包括: Root RenderSystem RenderWindow ...

  6. SecWeek

    “叮铃铃,叮铃铃”清晨闹钟如期而至,每天的这个时候都会是一天中最头痛的时刻,每日坚持早起,渐渐已经开始习惯,扶着沉重的额头,侧身翻起,会觉得世界都在天旋地转. 一个人,悄悄的开门,悄悄的刷牙洗脸,然后 ...

  7. 查看 并发请求数及其TCP连接状态【转】

    服务器上的一些统计数据: 1)统计80端口连接数netstat -nat|grep -i "80"|wc -l 2)统计httpd协议连接数ps -ef|grep httpd|wc ...

  8. Linux Pthread 深入解析(转-度娘818)

    Linux Pthread 深入解析   Outline - 1.线程特点 - 2.pthread创建 - 3.pthread终止         - 4.mutex互斥量使用框架         - ...

  9. HDU1434(终于用优先队列a了一题。。。了解度+1)

    #include<iostream> #include<cstdio> #include<cstring> #include<cmath> #inclu ...

  10. BLOCK封装带菊花的网络请求

    #import <Foundation/Foundation.h> @class HttpRequestManager; typedef void(^httpRequestBlock) ( ...