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

主框架搭建demo

时间:2016-03-05 11:38:49      阅读:106      评论:0      收藏:0      [点我收藏+]

标签:

- (void)viewDidLoad {

    [super viewDidLoad];
  
    [self setUpAllChildViewController];
}
  
/**
 *  添加所有子控制器方法
 */
- (void)setUpAllChildViewController{
    // 1.添加第一个控制器
    CYXOneViewController *oneVC = [[CYXOneViewController alloc]init];
    [self setUpOneChildViewController:oneVC image:[UIImage imageNamed:@"tab_home_icon"] title:@"首页"];
  
    // 2.添加第2个控制器
    CYXTwoViewController *twoVC = [[CYXTwoViewController alloc]init];
    [self setUpOneChildViewController:twoVC image:[UIImage imageNamed:@"js"] title:@"技术"];
  
    // 3.添加第3个控制器
    CYXThreeViewController *threeVC = [[CYXThreeViewController alloc]init];
    [self setUpOneChildViewController:threeVC image:[UIImage imageNamed:@"qw"] title:@"博文"];
  
    // 4.添加第4个控制器
    CYXFourViewController *fourVC = [[CYXFourViewController alloc]init];
    [self setUpOneChildViewController:fourVC image:[UIImage imageNamed:@"user"] title:@"我的江湖"];
}
  
/**
 *  添加一个子控制器的方法
 */
- (void)setUpOneChildViewController:(UIViewController *)viewController image:(UIImage *)image title:(NSString *)title{
  
    UINavigationController *navC = [[UINavigationController alloc]initWithRootViewController:viewController];
    navC.title = title;
    navC.tabBarItem.image = image;
    [navC.navigationBar setBackgroundImage:[UIImage imageNamed:@"commentary_num_bg"] forBarMetrics:UIBarMetricsDefault];
  
    viewController.navigationItem.title = title;
  
    [self addChildViewController:navC];
}

主框架搭建demo

标签:

原文地址:http://www.cnblogs.com/yinxiao-bai1014/p/5244314.html

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