有关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 ...
随机推荐
- 在Ubuntu 12.4 下安装 nginx, MySQL, PHP
LNMP是时下很流行的网站配置,我在配置蝉大师服务器的时候顺带把经验做个分享,蝉大师的网址是:http://www.ddashi.com/ 1.第一步, 跟新apt-get 输入: sudo apt- ...
- c# chart
1.随便一个例子 string sql = "select distinct count(*) as c,datepart(day,ull_loginTime) as a from user ...
- <mate>
1.<meta http-equiv="X-UA-Compatible" content="IE=edge"> 以最高级别的可用模式显示内容 有些因 ...
- iOS开发之APP上线
APP 上线有两种途径: 一种是 Xcode->openDeveloperTool->applicationLoader,这种打开后登陆appleID就可以选取并且交付您的应用程序了.这种 ...
- Python数学函数
1.Python数学函数 1.abs(x):取绝对值,内建函数 2.math.ceil(x):向上取整,在math模块中 3.cmp(x,y):如果 x < y ,返回-1:如果 x == y ...
- UITabBarButton 点击失效问题
开发过程: 在创建一个UIWindow时,直接在window上添加手势动作. 开发代码: UITapGestureRecognizer *tapRecognizer=[[UITapGestureRec ...
- Tomcat报错:Failed to start component [StandardEngine[Catalina].StandardHost[localhost]]
Failed to start component [StandardEngine[Catalina].StandardHost[localhost]] 解决办法: 1,检测你的web.xml.去掉所 ...
- 享元模式(Flyweight Pattern)
一.引言 在软件开发过程,如果我们需要重复使用某个对象的时候,如果我们重复地使用new创建这个对象的话,这样我们在内存就需要多次地去申请内存空间了,这样可能会出现内存使用越来越多的情况,这样的问题是非 ...
- MySql 的常用优化
1.选取最适用的字段属性 MySQL可以很好的支持大数据量的存取,但是一般说来,数据库中的表越小,在它上面执行的查询也就会越快.因此,在创建表的时候,为了获得更好的性能,我们可以将表中字段的宽度设得尽 ...
- 编程:使用递归方式判断某个字串是否回文(Palindrome)
Answer: import java.util.Scanner; public class Palindrome { private static int len;//全局变量整型数据 privat ...