有关TabBar的一些性质
// 计入导航控制器时,要使得底部的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的一些性质的更多相关文章
- uniapp-vuex实现tabbar提示点
底部入口栏的红点提示是app中常见的功能,或者说是必要功能,通常用来提醒用户去查看或操作某个模块内容. 看项目性质如果需要比较多并且灵活的提示,则需要用到长连接技术. 1.红点提示是根据接口返回的数据 ...
- B样条基函数的定义和性质
定义:令U={u0,u1,…,um}是一个单调不减的实数序列,即ui≤ui+1,i=0,1,…,m-1.其中,ui称为节点,U称为节点矢量,用Ni,p(u)表示第i个p次(p+1阶)B样条基函数,其定 ...
- 自定义tabBar
★★★★自定义tabBar★★★★★★★ Demo下载地址:https://github.com/marlonxlj/tabBarCustom.git 前言: 有的时候需求要对tabBar进行自定义的 ...
- react-native的tabbar和navigator混合使用
前段时间搭建项目使用了navigator和react-native-tab-navigator,现在我教大家搭建一个通用的简单框架. 先把几张图贴在这里,这就是我们今天要搭建的东西,别看页面简单,但是 ...
- iOS 切换首页-更改tabbar的容器控制器
最近想到的一个小需求: 首页切换:点击一个切换按钮,能实现首页的风格.排版等变换,原理是用一个新的VC替换掉. 效果如下: ====>====> 实现方式很简单: 以我的Demo为例, ...
- weui tabbar 切换
Html: <!DOCTYPE html> <html> <head> <meta charset="UTF-8"> <met ...
- 悬浮TabBar的实现--此段代码来自网络
悬浮TabBar的实现 这个TabBar看着像是用自定义TabBar做的,但事实上它还是用的系统的TabBar,给系统的tabBar.backgroundImage设置一张设计好的背景图片. TabB ...
- 项目中 -- 设置tabBar样式 (旅游局)
- (void)addChildViewController:(UIViewController *)ViewController image:(UIImage *)image selectImg:( ...
- iOS 有TabBar的VC界面push后隐藏TabBar的方法
当一个UITabbarController管理多个UINavigationController的时候, 我们要从这每一个UINavigationController中push一个ViewControl ...
随机推荐
- LayaAir引擎——(七)
LayaAir引擎——人物控制TiledMap地图移动和墙壁检测 所需要的软件: LayaAir IDE 1.0.2版本 TiledMap 所需要的东西: 地图:53 * 32,(48*48) 人物: ...
- 《看板与Scrum》读书笔记
看板的朴素思想:在制品(work-in-progress, WIP)必须被限制 WIP上限和拉动式生产 1. Scrum与看板简述 Scrum:组织拆分,工作拆分,开发时间拆分,优化发布计划,过程优化 ...
- Bullet的学习资源(用Doxygen生成API文档)
Bullet 全称 Bullet Physics Library,是著名的开源物理引擎(可用于碰撞检测.刚体模拟.可变形体模拟),这里将bullet的学习资源整理一下,希望能帮助入门者少走弯路. 看下 ...
- git format-patch & git apply & git clean
一.打补丁 git format-patch & git apply 最近在工作中遇到打补丁的需求,一来觉得直接传文件有些low(而且我尝试了一下,差点把项目代码毁了) ,二来也是想学习一下, ...
- springmvc学习笔记--ueditor和springmvc的集成
前言: 在web开发中, 富文本的编辑器真心很重要. 有电商店铺的打理, 新闻稿/博客文章/论坛帖子的编辑等等, 这种所见即所的编辑方式, 大大方便了非技术人员从事互利网相关的工作. 因为手头有个小项 ...
- 记录自己对EventLoop和性能问题处理的一点心得
1.EventLoop 这里说的EventLoop不是指某一个具体的库或是框架,而是指一种程序实现结构.这种结构多是基于IO多路转接的API(select.poll.epoll之类)以reactor模 ...
- web安全之sqlload_file()和into outfile()
load_file() 条件:要有file_priv权限 知道文件的绝对路径 能使用union 对web目录有读权限 如果过滤啦单引号,则可以将函数中的字符进行hex编码 步骤: 1.读/etc/in ...
- appserver安装常见的问题
安装过程: 一般下载安装包直接按照步骤安装,不过一次安装好没问题的情况很少. 1. 下载安装包百度搜索appserv 或者到以下网址下载 http://www.appservnetwork ...
- Retrofit学习笔记01
retrofit把你的HTTP API改造成java接口. public interface GitHubService { @GET("users/{user}/repos") ...
- 集成Visual Studio/MSBuild的开发/发布流程和 FIS3
谁不想让自己的网站速度更快?为此需要多方面的优化,但优化又会增加开发工作量.Fis3 是很不错的前端优化工具,能够让前端的优化变得自动方便,解决前述问题.Fis3是百度开发的,开源的,在国内比较六流行 ...