// 计入导航控制器时,要使得底部的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. 【HTML5】canvas画布练习

    第一步:获取画布元素 var canvas = document.getElementById("myCanvas"); var context = canvas.getConte ...

  2. js用户修改密码功能模块

    ;(function(){ var ajaxSub = false, showError = function(msg){ if(msg){ $('#er_txt').html(msg).show() ...

  3. libevent之丢失header问题

    本文为原创,转载请注明:http://www.cnblogs.com/gistao/ 背景 分享一个hhvm使用http server方式来处理请求的问题及对应的patch.hhvm3+版本支持fas ...

  4. HDU 1285 确定比赛排名 (数组实现 )

    题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=1285 确定比赛名次 Time Limit: 2000/1000 MS (Java/Others)    ...

  5. 最近这两天看了关于H5游戏开发的一个教程,实践很短暂,看了很多理论的东西,现在呢也只是想回忆回忆关于EUI的部分知识吧

    首先我了解了什么是Egret: Egret中文就是白鹭的意思,Egret是一套H5游戏开发的软件.(纯粹属于个人理解) 其次我对以下几款软件的相关知识做了些了解: Egret Engine(引擎),E ...

  6. getEnhancedMicrophone 方法

    [转]http://www.cnblogs.com/iBlogger/archive/2011/11/16/2251847.html Flex 4.6 SDK 提供了 getEnhancedMicro ...

  7. pwnable echo1

    最近忙的好久没有更新了,有空把之前拿来练手的CTF pwn题逐渐整理一下放出来 题目是 linux 64位程序 ,流程很简单,大致思路就是先把一个跳转的机器指令写进name的地址,然后溢出覆盖eip, ...

  8. 用Join子句进行分组联接

    using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.T ...

  9. JAVA之Forward 和 Redirect的区别

    1.从地址栏显示来说forward是服务器请求资源,服务器直接访问目标地址的URL,把那个URL的响应内容读取过来,然后把这些内容再发给浏览器.浏览器根本不知道服务器发送的内容从哪里来的,所以它的地址 ...

  10. 格式化xml

    在程序代码开发过程中,我们可能有时候需要将xml报文进行格式化一下,整理了一下,大概有两种方法: public String formatXml(String inputXml){ SAXReader ...