设置UITabBarController的用法
来源:互联网 发布:淘宝能不能卖保健品 编辑:程序博客网 时间:2024/04/30 20:11
设置UITabBarController的用法的一个示例
#import "TabBarCtrl.h"#import "HomeCtrl.h"#import "TrainCtrl.h"#import "WeatherCtrl.h"@interface TabBarCtrl ()@end@implementation TabBarCtrl- (void)viewDidLoad { [super viewDidLoad]; //设置控制器的文字和图片 UIStoryboard *homeStory = [UIStoryboard storyboardWithName:@"HomeCtrl" bundle:nil]; //装载Storyboard中的ViewController HomeCtrl *homeCtrl = [homeStory instantiateViewControllerWithIdentifier:@"HomeCtrlId"]; [self addChildCtrl:homeCtrl title:@"站点查询" image:@"tabbar_home.png" selectedImage:@"tabbar_home_selected.png"]; UIStoryboard *trainStory = [UIStoryboard storyboardWithName:@"TrainCtrl" bundle:nil]; TrainCtrl *trainCtrl = [trainStory instantiateViewControllerWithIdentifier:@"TrainCtrlId"]; [self addChildCtrl:trainCtrl title:@"车次查询" image:@"tabbar_query.png" selectedImage:@"tabbar_query_selected.png"]; UIStoryboard *weatherStory = [UIStoryboard storyboardWithName:@"WeatherCtrl" bundle:nil]; WeatherCtrl *weatherCtrl = [weatherStory instantiateViewControllerWithIdentifier:@"WeatherCtrlId"]; [self addChildCtrl:weatherCtrl title:@"天气查询" image:@"1.gif" selectedImage:@"1.gif"]; }- (void) addChildCtrl:(UIViewController *)childCtrl title:(NSString *) title image:(NSString *) image selectedImage:(NSString *) selectedImage{ //设置控制器的文字和图片 childCtrl.title = title; // childCtrl.tabBarItem.title = title; // childCtrl.navigationItem.title = title; childCtrl.tabBarItem.image = [UIImage imageNamed:image]; childCtrl.tabBarItem.selectedImage = [[UIImage imageNamed:selectedImage] imageWithRenderingMode:UIImageRenderingModeAlwaysOriginal]; //设置文字的样式 NSMutableDictionary *SelectedTextAttrs = [NSMutableDictionary dictionary]; //下面的这种用法相当于array[下标],设置<span style="font-family: Menlo;">NSForegroundColorAttributeName的值</span> SelectedTextAttrs [NSForegroundColorAttributeName] = [UIColor orangeColor]; [childCtrl.tabBarItem setTitleTextAttributes:SelectedTextAttrs forState:UIControlStateSelected]; UINavigationController *navigation = [[UINavigationController alloc] initWithRootViewController:childCtrl]; [self addChildViewController:navigation]; }@end
效果图如下:
1 0
- 设置UITabBarController的用法
- ios--UITabBarController的用法
- iOS中UITabbarController的用法
- 设置UITabBarController的图片问题
- UITabBarController的一些基础设置
- 【iOS开发-UITabBarController】UITabBarController上面的UINavigationController的设置
- UITabBarController用法
- UITabBarController用法
- UITabBarController用法
- uitabbarcontroller上的tabbaritem的图片设置
- ios--UITabBarController的基本用法3
- UITabBarController详解(一)UITabBarController的介绍和设置(偷了点懒,直接用了ARC)
- Swift UITabBarController 基本用法
- UITabBarController用法原理详解
- UINavigationController UITabBarController设置title
- UITabBarController,UITabBarItem设置
- Object-c设置UITabBarController
- Swift 设置UITabBarController
- SQL优化:重新编译存储过程和表
- nand bad---fwqlzz love is for ever
- EditPlus实现文件编码批量转换
- ListView使用技巧(一):ViewHolder
- CC2541之配对与绑定
- 设置UITabBarController的用法
- redis中使用 check-and-set 操作实现乐观锁
- 题目1023:EXCEL排序 学习
- “词”向量应用的一些思考
- 浅谈HTTP中Get与Post的区别
- Cocosd2d-js 使用Cocos Studio生成的Json界面文件
- Activity的四种launchMode
- 发短信
- c++使用rapidxml读取cocos2dx的配置文件