tabbar代码加载。设置tabbaritem的title和image

   rootViewController = [[UITabBarController alloc] init];
    
    //初始化tabBar上面的所有视图控制器
    picker1Controller = [[Picker1ViewController alloc] init];
    picker2Controller = [[Picker2ViewController alloc] init];

    [picker1Controller.tabBarItem initWithTitle:@"pick1" image:[UIImage imageNamed:@"pick1.png"] tag:1];
    [picker2Controller.tabBarItem initWithTitle:@"pick2" image:[UIImage imageNamed:@"pick2.png"] tag:2];
    这样连图片都有了
    但是图片得是30*30的

    controllersOfTabBar = [[NSMutableArray alloc] init];
    [controllersOfTabBar addObject:picker1Controller];
    [controllersOfTabBar addObject:picker2Controller];
    
    rootViewController.viewControllers = controllersOfTabBar;
    rootViewController.selectedViewController = picker1Controller;
    
    [window addSubview:rootViewController.view];
        [window makeKeyAndVisible];

你可能感兴趣的:(image)