新浪微博客户端(1)-实现Tabbar导航栏效果
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {
// 1. 创建窗口
self.window = [[UIWindow alloc] init];
self.window.frame = [UIScreen mainScreen].bounds;
// 2. 设置根控制器
UITabBarController *tabbarVc = [[UITabBarController alloc] init];
self.window.rootViewController = tabbarVc;
// 3. 设置子控制器属性
DJHomeViewController *homeVc = [[DJHomeViewController alloc] init];
[self setChildVc:homeVc withTitle:@"首页" image:@"tabbar_home" selectedImage:@"tabbar_home_selected"];
DJMessageCenterViewController *messageCenterVc = [[DJMessageCenterViewController alloc] init];
[self setChildVc:messageCenterVc withTitle:@"消息" image:@"tabbar_message_center" selectedImage:@"tabbar_message_center_selected"];
DJDiscoverViewController *discoverVc = [[DJDiscoverViewController alloc] init];
[self setChildVc:discoverVc withTitle:@"发现" image:@"tabbar_discover" selectedImage:@"tabbar_discover_selected"];
DJProfileViewController *profileVc = [[DJProfileViewController alloc] init];
[self setChildVc:profileVc withTitle:@"我" image:@"tabbar_profile" selectedImage:@"tabbar_profile_selected"];
// 4. 添加子控制器
[tabbarVc addChildViewController:homeVc];
[tabbarVc addChildViewController:messageCenterVc];
[tabbarVc addChildViewController:discoverVc];
[tabbarVc addChildViewController:profileVc];
// 5. 显示窗口
[self.window makeKeyAndVisible];
return YES;
}
- (void)setChildVc:(UIViewController *)vc withTitle:(NSString *)title image:(NSString *)image selectedImage:(NSString *)selectedImage {
vc.view.backgroundColor = DJRandomColor;
vc.tabBarItem.title = title;
// 设置tabbarItem 选中图片
vc.tabBarItem.image = [UIImage imageNamed:image];
vc.tabBarItem.selectedImage = [[UIImage imageNamed:selectedImage] imageWithRenderingMode:UIImageRenderingModeAlwaysOriginal];
// 设置tabarItem 选中颜色
NSMutableDictionary *textAttrs = [NSMutableDictionary dictionary];
textAttrs[NSForegroundColorAttributeName] = DJColor(, , );
NSMutableDictionary *selectedTextAttrs = [NSMutableDictionary dictionary];
selectedTextAttrs[NSForegroundColorAttributeName] = [UIColor orangeColor];
[vc.tabBarItem setTitleTextAttributes:textAttrs forState:UIControlStateNormal];
[vc.tabBarItem setTitleTextAttributes:selectedTextAttrs forState:UIControlStateSelected];
}
最终效果:

新浪微博客户端(1)-实现Tabbar导航栏效果的更多相关文章
- 微信小程序------导航栏样式、tabBar导航栏
一:导航栏样式设置 小程序的导航栏样式在app.json中定义. 这里设置导航,背景黑色,文字白色,文字内容测试小程序 app.json内容: { "pages":[ " ...
- 微信小程序入门四: 导航栏样式、tabBar导航栏
实例内容 导航栏样式设置 tabBar导航栏 实例一:导航栏样式设置 小程序的导航栏样式在app.json中定义. 这里设置导航,背景黑色,文字白色,文字内容测试小程序 app.json内容: { & ...
- 【分享】纯jQuery实现星巴克官网导航栏效果
前言 大冬天的没得玩,只能和代码玩. 所以就无聊研究了一下星巴克官网,在我看来应该是基本还原吧~ 请各位大神指教! 官网效果图 要写的就是最上方的会闪现的白色条条 效果分析 1.在滚动条往下拉到一定距 ...
- 移动端如何用swiper实现导航栏效果
在移动端如何用swiper实现导航栏效果 我们在写移动端的时候会有滑动和点击导航后滑动到目标页面功能:而这个功能如果自己写的话会很麻烦,所以我在这推荐一下swiper这个插件. 其实swiper中的官 ...
- 【方法】纯jQuery实现星巴克官网导航栏效果
前言 大冬天的没得玩,只能和代码玩. 所以就无聊研究了一下星巴克官网,在我看来应该是基本还原吧~ 请各位大神指教! 官网效果图 要写的就是最上方的会闪现的白色条条 效果分析 1.在滚动条往下拉到一定距 ...
- Android之仿今日头条顶部导航栏效果
随着时间的推移现在的软件要求显示的内容越来越多,所以要在小的屏幕上能够更好的显示更多的内容,首先我们会想到底部菜单栏,但是有时候像今日头条新闻客户端要显示的内容太多,而且又想在主界面全部显示出来,所以 ...
- css3制作炫酷导航栏效果
今天主要利用hover选择器.鼠标滑过查看效果. 一.普通导航栏 Home Content Service Team Contact 对于这种普通的导航栏,只是鼠标滑过的时候颜色会变,所以思路变得很简 ...
- Android仅2步实现 滚粗 汉堡导航栏效果~ 全新底部导航交互(滑动隐藏)
本文同步自wing的地方酒馆 布吉岛大家有木有看这一篇文章,再见,汉堡菜单,我们有了新的 Android 交互设计方案 本库下载地址:https://github.com/githubwing/Bye ...
- Flutter - TabBar导航栏切换后,状态丢失
上一篇讲到了 Flutter - BottomNavigationBar底部导航栏切换后,状态丢失 里面提到了TabBar,这儿专门再写一下吧,具体怎么操作,来不让TabBar的状态丢失.毕竟大家99 ...
随机推荐
- Tomcat中部署后JspFactory报异常的解决方案
The method getJspApplicationContext(ServletContext) is undefined for the type JspFactory的异常的原因及解决办法原 ...
- 各种python环境的问题
[OS] mac [ERROR] decoder jpeg not available [SOLUTION] $ pip uninstall pillow $ brew install libjpeg ...
- LeetCode:Search Insert Position,Search for a Range (二分查找,lower_bound,upper_bound)
Search Insert Position Given a sorted array and a target value, return the index if the target is fo ...
- LINUX信息安全系统设计基础第二周学习总结
1 Linux命令 2 man命令 1.Terminal(终端) Linux 系统还提供了一个叫做终端模拟器的程序(Terminal),下面几个比较常见的终端模拟器,例如 gnome-terminal ...
- 【MyEclipse 2015】 逆向破解实录系列【终】(纯研究)
声明 My Eclipse 2015 程序版权为Genuitec, L.L.C所有. My Eclipse 2015 的注册码.激活码等授权为Genuitec, L.L.C及其付费用户所有. 本文只从 ...
- python&MongoDB爬取图书馆借阅记录(没有验证码)
题外话:这个爬虫本来是想用java完成然后发布在博客园里的,但是一直用java都失败了,最后看到别人用了python,然后自己就找别人问了问关键的知识点,发现连接那部分,python只用了19行!!! ...
- EntityFramework:值不能为 null。参数名: entitySet 异常解决方案
昨天EF莫名其妙的,掉所有接口访问都出现如下错误:百度,Google了半天,倒是有很多人都遇到了这个问题,但都没有一个解决方案,或者解决方案无效.通过层层排除,终于找到问题的所在.记录下来,给以后再遇 ...
- AngularJS——karma的安装
1,前言: 刚刚学过了 grunt的安装以及使用,grunt的作用就是让我们平常不想做的任务能够自动化完成,并且可以自己 自定义任务,那么karma是什么呢? Karma是Testcular的新名字, ...
- ansible 配置运行环境
P34 2.3.1 配置ansible的环境 ansible的配置文件是以ini格式存储配置数据的,在ansible中几乎所有的配置都可以通过playbook或者环境变量来重新赋值 运行ansible ...
- ADHelper C#域用户操作(转)
using System; using System.Collections.Generic; using System.DirectoryServices; using System.Linq; u ...