You can use hidesBottomBarWhenPushed to hide a page.
Step 1: We need some images:
The icons of each option and the background image of tabbar are also a transparent 1x1 pixel image.
Step 2: Create a project and create a class in the project that inherits from UITabBarController.
Step 3: first write a method and return a UINavigationController
-(UINavigationController*) viewControllerWithTitle:(NSString*) title image:(UIImage*)image{ UIViewController* viewController = [[UIViewController alloc] init]; viewController.tabBarItem = [[UITabBarItem alloc] initWithTitle:title image:image tag:0]; viewController.title = title; UINavigationController *nav = [[UINavigationController alloc]initWithRootViewController:viewController]; return nav;}
Then, create viewControllers of TabbarController in viewDidLoad.
self.viewControllers = [NSArray arrayWithObjects: [self viewControllerWithTitle:@"1" image:IMG(@"1")], [self viewControllerWithTitle:@"2" image:IMG(@"2")], [self viewControllerWithTitle:nil image:nil], [self viewControllerWithTitle:@"3" image:IMG(@"3")], [self viewControllerWithTitle:@"4" image:IMG(@"4")], nil];
No. The third ViewController is not set.
Because we need to put a button at that position and continue to write in viewDidLoad:
UIButton* button = [[UIButton alloc]initWithFrame:CGRectMake(0.0, 0.0, 65, 65)]; button.center = CGPointMake(160, 20); [button setBackgroundImage:IMG(@"add") forState:UIControlStateNormal]; [button addTarget:self action:@selector(add:) forControlEvents:UIControlEventTouchUpInside]; [self.tabBar addSubview:button];
Then set the background image:
[self.tabBar setBackgroundImage:IMG(@"tabbarbg")];
After running:
You will find that there is a horizontal line on the button, and then set this shadow to run, no one will find you wretched behavior.
[self.tabBar setShadowImage:IMG(@"transparent")];
Finally (iOS7 and iOS6 ):
Download