适用于iPhone的自定义Tabbar控制器

时间:2012-08-10 06:35:34

标签: iphone uitabbarcontroller

我尝试为iPhone创建框架,并尝试在我的框架中实现自定义Tabbar控制器。任何人都可以帮我为iPhone创建自定义标签栏控制器。我的意思是以编程方式添加标签栏控制器。

2 个答案:

答案 0 :(得分:0)

答案 1 :(得分:0)

To create tab bar give this code in AppDelegate.m

- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
{
  UIViewController *viewController1, *viewController2,*viewController3;

  viewController1 = [[FirstViewController alloc] initWithNibName:@"FirstViewControllerXibname" bundle:nil];
  viewController2 = [[SecondViewController alloc] initWithNibName:@"SecondViewControllerXibname" bundle:nil];
  viewController3 = [[ThirdViewController alloc] initWithNibName:@"ThirdViewControllerXibname" bundle:nil];


  self.tabBarController = [[UITabBarController alloc] init];
  self.tabBarController.viewControllers = [NSArray arrayWithObjects:viewController1, viewController2,viewController3, nil];
  self.window.rootViewController = self.tabBarController;
  [self.window makeKeyAndVisible];


   self.tabBarController.moreNavigationController.navigationBar.tintColor =[UIColor darkTextColor];

  [[UITabBar appearance] setSelectedImageTintColor:[UIColor yellowColor]]; //change selected image color on tabbatItem

  self.tabBarController.moreNavigationController.navigationBar.barStyle = UIBarStyleBlackOpaque;

  [self.tabBarController.tabBar setOpaque:YES];
  return YES;
}