百思学习笔记03-appearance
来源:互联网 发布:java se到底是什么 编辑:程序博客网 时间:2024/05/16 11:38
用appearance来精简代码
// 通过appearance统一设置所有UITabBarItem的文字属性 // 后面带有UI_APPEARANCE_SELECTOR的方法, 都可以通过appearance对象来统一设置 NSMutableDictionary *attrs = [NSMutableDictionary dictionary]; attrs[NSFontAttributeName] = [UIFont systemFontOfSize:12]; attrs[NSForegroundColorAttributeName] = [UIColor grayColor]; NSMutableDictionary *selectedAttrs = [NSMutableDictionary dictionary]; selectedAttrs[NSFontAttributeName] = attrs[NSFontAttributeName]; selectedAttrs[NSForegroundColorAttributeName] = [UIColor darkGrayColor]; UITabBarItem *item = [UITabBarItem appearance]; [item setTitleTextAttributes:attrs forState:UIControlStateNormal]; [item setTitleTextAttributes:selectedAttrs forState:UIControlStateSelected]; // 添加子控制器 UIViewController *vc01 = [[UIViewController alloc] init]; vc01.tabBarItem.title = @"精华"; vc01.tabBarItem.image = [UIImage imageNamed:@"tabBar_essence_icon"]; vc01.tabBarItem.selectedImage = [UIImage imageNamed:@"tabBar_essence_click_icon"]; vc01.view.backgroundColor = [UIColor redColor]; [self addChildViewController:vc01]; UIViewController *vc02 = [[UIViewController alloc] init]; vc02.tabBarItem.title = @"新帖"; vc02.tabBarItem.image = [UIImage imageNamed:@"tabBar_new_icon"]; vc02.tabBarItem.selectedImage = [UIImage imageNamed:@"tabBar_new_click_icon"]; vc02.view.backgroundColor = [UIColor grayColor]; [self addChildViewController:vc02]; UIViewController *vc03 = [[UIViewController alloc] init]; vc03.tabBarItem.title = @"关注"; vc03.tabBarItem.image = [UIImage imageNamed:@"tabBar_friendTrends_icon"]; vc03.tabBarItem.selectedImage = [UIImage imageNamed:@"tabBar_friendTrends_click_icon"]; vc03.view.backgroundColor = [UIColor greenColor]; [self addChildViewController:vc03]; UIViewController *vc04 = [[UIViewController alloc] init]; vc04.tabBarItem.title = @"我"; vc04.tabBarItem.image = [UIImage imageNamed:@"tabBar_me_icon"]; vc04.tabBarItem.selectedImage = [UIImage imageNamed:@"tabBar_me_click_icon"]; vc04.view.backgroundColor = [UIColor blueColor]; [self addChildViewController:vc04];
0 0
- 百思学习笔记03-appearance
- 03百思不得姐appearance使用
- UIBarButtonItem appearance学习
- ios学习笔记——ios内的控件自定义(appearance)
- iOS学习之——Appearance
- Bug笔记:-webkit-appearance:none导致无法获取checkbox值
- 论文笔记--Appearance-and-Relation Networks for Video Classification
- IOS 杂笔-13(appearance的巧妙使用)
- appearance一键换肤
- appearance属性:
- A Survey of Appearance Models in Visual Object Tracking 阅读笔记(一)
- A Survey of Appearance Models in Visual Object Tracking 阅读笔记(二)
- A Survey of Appearance Models in Visual Object Tracking 阅读笔记(三)
- iOS:UINavigationBar appearance与UIBarButtonItem appearance简介
- 客串演出 cameo appearance
- appearance 取消默认样式
- 设置UIBarButtonItem appearance
- mono touch: Appearance API
- Button selector的使用
- FragmentManager API
- 【5-1】ZooKeeper介绍
- 二叉树(四)
- 一份报告引发的血案:二手车电商老大车易拍被黑的72小时
- 百思学习笔记03-appearance
- js confirm框的用法
- 新年伊始,开始写写技术blog。
- 美国狙击手 American.Sniper.(2014).iNT.BDRip.720p.AC3.X264-TLF
- CAS部署错误2:java.security.UnrecoverableKeyException: Cannot recover key
- JNI Android Studio 调试
- Android设计中的.9.png与Android Studio中的设置
- 字段权限构件
- POJ 1276(多重背包)