UITabBarController
来源:互联网 发布:无基础学编程 知乎 编辑:程序博客网 时间:2024/04/30 02:08
- (void)creatTabbar
{
UITabBarController* rootVC = [[UITabBarControlleralloc] init];
//类、标题、图片、点击时的图片
NSArray* classNames =@[@"YQLimitFreeViewController",@"YQSaleViewController",@"YQFreeViewController",@"YQSubViewController",@"YQHotViewController"];
NSArray* titles =@[@"限免",@"降价",@"免费",@"专题",@"热榜"];
NSArray* imageNames =@[@"tabbar_limitfree",@"tabbar_reduceprice",@"tabbar_appfree",@"tabbar_subject",@"tabbar_rank"];
NSArray* selectImageNames =@[@"tabbar_limitfree_press",@"tabbar_reduceprice_press",@"tabbar_appfree_press",@"tabbar_subject_press",@"tabbar_rank_press"];
//tabbar的子视图数组
NSMutableArray* childVCs = [[NSMutableArrayalloc] init];
for (int i=0; i<classNames.count; i++) {
//通过数组取“类”
NSString* className = classNames[i];
Class name =NSClassFromString(className);
//子类实例化父类的实例(多态)
YQRootViewController* VC = [[name alloc] init];
NSString* imageName = imageNames[i];
NSString* selectImageName = selectImageNames[i];
UITabBarItem* item = [[UITabBarItemalloc] initWithTitle:titles[i]image:[UIImageimageNamed:imageName] selectedImage:[UIImage imageNamed:selectImageName]];
[VCsetTabBarItem:item];
UINavigationController* nav = [[UINavigationControlleralloc] initWithRootViewController:VC];
[childVCsaddObject:nav];
}
[rootVC.tabBarsetBackgroundImage:[UIImageimageNamed:@"tabbar_bg"]];
[rootVCsetViewControllers:childVCs];
self.window.rootViewController = rootVC;
}
- UITabbarController
- UITabBarController
- UITabBarController
- UITabBarController
- UITabBarController
- UITabBarController
- UITabbarController
- UITabBarController
- UITabBarController
- UITabBarController
- UITabbarController
- UITabBarController
- UITabBarController
- UITabBarController
- UITabBarController
- UITabBarController
- UITabBarController
- UITabBarController
- 痔疮是什么呢?
- rac_grid自检提示缺少pdksh-5.2包
- select 1 from的浅析
- FLASH实现ASP.NET MVC上传---.NET篇
- AndroidAnnotations 是如何工作的
- UITabBarController
- Clojure Dev. on Eclipse
- 【cocos2d-html5、cocos2dx+jsbinding、cocos2dx-lua】
- git 远程分支同步
- 上机作业求三角形
- 求20个整数之和
- AndroidManifest.xml配置文件详解
- poj 1845 Sumdiv (同余定理,快速幂取余)
- wikioi 2822 爱在心中