- (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导航栏效果的更多相关文章

  1. 微信小程序------导航栏样式、tabBar导航栏

    一:导航栏样式设置 小程序的导航栏样式在app.json中定义. 这里设置导航,背景黑色,文字白色,文字内容测试小程序 app.json内容: { "pages":[ " ...

  2. 微信小程序入门四: 导航栏样式、tabBar导航栏

    实例内容 导航栏样式设置 tabBar导航栏 实例一:导航栏样式设置 小程序的导航栏样式在app.json中定义. 这里设置导航,背景黑色,文字白色,文字内容测试小程序 app.json内容: { & ...

  3. 【分享】纯jQuery实现星巴克官网导航栏效果

    前言 大冬天的没得玩,只能和代码玩. 所以就无聊研究了一下星巴克官网,在我看来应该是基本还原吧~ 请各位大神指教! 官网效果图 要写的就是最上方的会闪现的白色条条 效果分析 1.在滚动条往下拉到一定距 ...

  4. 移动端如何用swiper实现导航栏效果

    在移动端如何用swiper实现导航栏效果 我们在写移动端的时候会有滑动和点击导航后滑动到目标页面功能:而这个功能如果自己写的话会很麻烦,所以我在这推荐一下swiper这个插件. 其实swiper中的官 ...

  5. 【方法】纯jQuery实现星巴克官网导航栏效果

    前言 大冬天的没得玩,只能和代码玩. 所以就无聊研究了一下星巴克官网,在我看来应该是基本还原吧~ 请各位大神指教! 官网效果图 要写的就是最上方的会闪现的白色条条 效果分析 1.在滚动条往下拉到一定距 ...

  6. Android之仿今日头条顶部导航栏效果

    随着时间的推移现在的软件要求显示的内容越来越多,所以要在小的屏幕上能够更好的显示更多的内容,首先我们会想到底部菜单栏,但是有时候像今日头条新闻客户端要显示的内容太多,而且又想在主界面全部显示出来,所以 ...

  7. css3制作炫酷导航栏效果

    今天主要利用hover选择器.鼠标滑过查看效果. 一.普通导航栏 Home Content Service Team Contact 对于这种普通的导航栏,只是鼠标滑过的时候颜色会变,所以思路变得很简 ...

  8. Android仅2步实现 滚粗 汉堡导航栏效果~ 全新底部导航交互(滑动隐藏)

    本文同步自wing的地方酒馆 布吉岛大家有木有看这一篇文章,再见,汉堡菜单,我们有了新的 Android 交互设计方案 本库下载地址:https://github.com/githubwing/Bye ...

  9. Flutter - TabBar导航栏切换后,状态丢失

    上一篇讲到了 Flutter - BottomNavigationBar底部导航栏切换后,状态丢失 里面提到了TabBar,这儿专门再写一下吧,具体怎么操作,来不让TabBar的状态丢失.毕竟大家99 ...

随机推荐

  1. LeetCode 笔记26 Single Number II

    Given an array of integers, every element appears three times except for one. Find that single one. ...

  2. .tostring()格式化大全

    C 货币 2.5.ToString("C") ¥2.50 D 十进制数 25.ToString("D5") 00025 E 科学型 25000.ToString ...

  3. javascript中prototype、constructor以及__proto__之间的三角关系

    三者暧昧关系简单整理 在javascript中,prototype.constructor以及__proto__之间有着“著名”的剪不断理还乱的三角关系,楼主就着自己对它们的浅显认识,来粗略地理理以备 ...

  4. Android空闲教室查询-资料

    这是去年某课程的一个称作“研究型学习”的东西的报告的展示PPT,有点失败的是这个APP的名字起得不太好……PPT上的功能都实现了,其他功能都没有.一年了,程序都忘差不多了,也暂时没有时间分享.就先把P ...

  5. 获取Web.config配置节

    static string GetAppSetting(string key) { var appSetting = ConfigurationManager.AppSettings[key]; if ...

  6. [bzoj 2005][NOI 2010]能量采集(容斥原理+递推)

    题目:http://www.lydsy.com/JudgeOnline/problem.php?id=2005 分析:首先易得ans=∑gcd(x,y)*2+1 然后我就布吉岛了…… 上网搜了下题解, ...

  7. ThinkPHP中简单的CURD操作

    前言 我们通过一个简答例子来简述CURD的操作.首先看一下数据库的样子,其中id为自增行,其它是varchar 一.查询操作 首先,创建在Controller文件夹下创建一个User控制器,在该控制器 ...

  8. JAVA并发的性能调整

    1.互斥技术 synchronized Lock Atomic 性能比较Atomic >  Lock  > synchronized,当然这不是绝对的.当线程数比较少时,synchroni ...

  9. JavaScript、jQuery、AJAX、JSON 解释

  10. MVC4学习笔记(一)

    1.查询 1)Controllers /// <summary> /// 数据上下文对象 /// </summary> OumindBlogEntities db = new ...