码迷,mamicode.com
首页 > 其他好文 > 详细

创建TabBar

时间:2015-05-31 16:45:29      阅读:146      评论:0      收藏:0      [点我收藏+]

标签:

-(void)creatTabBarView
{
    NSArray *imgArray=@[];
    NSArray *selectImage=@[];

    NSArray *names=@[];
    for (int i=0; i<names.count; i++) 
  { //Class 为类的泛型,泛指任意类,id为对象的泛指 Class class=NSClassFromString(names[i]); UIViewController *root=[[class alloc] init]; [self addChlildVc:root imageName:imgArray[i] selectedImageName:selectImage[i]]; } } // 给 tabBar 设置图片 - (void)addChlildVc:(UIViewController *)childVc imageName:(NSString *)imageName selectedImageName:(NSString *)selectedImageName { // 设置图标 UIImage *image = [UIImage imageNamed:imageName]; image = [image imageWithRenderingMode:UIImageRenderingModeAlwaysOriginal]; childVc.tabBarItem.image = image; // 设置选中的图标 UIImage *selectedImage = [UIImage imageNamed:selectedImageName]; selectedImage = [selectedImage imageWithRenderingMode:UIImageRenderingModeAlwaysOriginal]; childVc.tabBarItem.selectedImage = selectedImage; //解决7.1版本图标不自适应 if ([UIParam getIOSVersion] <= 7.1) { childVc.tabBarItem.imageInsets = UIEdgeInsetsMake(30, 42, 18, 42); } UINavigationController *nav = [[UINavigationController alloc] initWithRootViewController:childVc]; [self addChildViewController:nav]; }

 

创建TabBar

标签:

原文地址:http://www.cnblogs.com/SimonGao/p/4542177.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!