The implementation of the effect is probably like this, the picture is not good-looking, live to see
Just stick to the code.
First create a Singleview program
Change Viewcontroller base class to Uitabbarcontroller
Then write the. m file as follows [PS I'm open arc]
- (void) viewdidload { [super viewdidload]; // Do any additional setup after loading the view, typically from a nib. [self initowncontrollers]; [self initowntabview]; [self.tabbar sethidden:yes];} /* * set multiple tabs, in order to toggle **/- (void) Initowncontrollers{ nsarray *array = @[@ "Home", @ "more", @ "file", @ "info", @ "discover"]; // each tab title NSMutableArray *conArray = [[NSMutableArray alloc] init]; for (Nsstring *object in array) { // Traverse uiviewcontroller *con = [[ uiviewcontroller alloc] init]; con.title = object; // set the navigation bar to show the title, which makes it easy to tell which page to switch to uinavigationcontroller *controll = [[UINavigationController alloc] initWithRootViewController:con]; [conArray addObject:controll]; } self.viewcontrollers = conarray;} /* * defines its own tabbar **/- (void) initowntabview{ uiview *view = [[uiview alloc] initwithframe:cgrectmake (5, 519, 310, 44)]; // Use the latest xcode, coordinate a bit of a problem, adjust it yourself view.backgroundColor = [UIColor whiteColor]; view.layer.cornerRadius = 9; // set rounded corners, nice points // load each button's picture nsarray *imagearray = @[@ "Home.png", @ "Much.png", @ "file.png", @ "Message.png", @ " Discover.png "]; for (int index = 0; index < [ imagearray count]; index++) { uibutton * button = [uibutton buttonwithtype:uibuttontypesystem]; [button setimage:[uiimage imagenamed:imagearray[index]] forstate: Uicontrolstatenormal]; [button addtarget:self action: @selector (pagechanged:) forControlEvents:UIControlEventTouchDown]; button.frame = cgrectmake (21+index*62, 7, 30, 30); // This coordinate should be set correctly button.tag = index; // set Tag to conveniently set switch pages [view addSubview:button]; } [self.view addsubview:view];} - (void) pagechanged: (uibutton *) button{ self.selectedindex = button.tag; // the event handling of its own button}
Implementation of IOS Custom Tabbar