tabBar = [[UITabBarController alloc] init]; tabBar.delegate = self; Page1* blueViewController = [[Page1 alloc] init]; Page2* yellowViewController = [[Page2 alloc] init]; NSArray *viewControllerArray = [NSArray arrayWithObjects:blueViewController,yellowViewController,nil]; tabBar.viewControllers = viewControllerArray; tabBar.view.frame = CGRectMake(0, 0, self.view.frame.size.width, self.view.frame.size.height); [self.view addSubview:tabBar.view]; [viewControllerArray release]; 、、、、、、、、、、、、 - (id)initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil { self = [super initWithNibName:nibNameOrNil bundle:nibBundleOrNil]; if (self) { // Custom initialization UITabBarItem *item = [[UITabBarItem alloc] initWithTitle:@"礼品" image:[UIImage imageNamed:@"礼品.png"] tag:1]; self.tabBarItem = item; [item release]; } return self; }
[self.tabBarController.tabBar setSelectedImageTintColor:[UIColor greenColor]];