Create a project on the iOS platform, then create two class views in the project as follows 1, set the background color for the main view in two class views respectively firstviewcontroller.m
#import "FirstViewController.h"
@interface Firstviewcontroller ()
@end
@implementation Firstviewcontroller
-(void) Viewdidload {
[Super Viewdidload];
Set the background color of the main view
Self.view.backgroundcolor=[uicolor Greencolor]; } SECONDVIEWCONTROLLER.M
#import "SecondViewController.h"
@interface Secondviewcontroller ()
@end
@implementation Secondviewcontroller
-(void) Viewdidload {
[Super Viewdidload];
Set the background color of the main view
Self.view.backgroundcolor=[uicolor Bluecolor]; }2, inCreate navigation bar and root view in Appdelegate AppDelegate.h
#import <UIKit/UIKit.h>
#import "FirstViewController.h"
#import "SecondViewController.h"
@interface Appdelegate:uiresponder <UIApplicationDelegate>
@property (Strong, nonatomic) UIWindow *window;
@end APPDELEGATE.M
#import "AppDelegate.h"
@interface Appdelegate ()
@end
@implementation Appdelegate
-(BOOL) Application: (UIApplication *) application didfinishlaunchingwithoptions: (Nsdictionary *) launchOptions {
Create a View object
Firstviewcontroller *firstvc=[[firstviewcontroller Alloc]init];
Secondviewcontroller *secondvc=[[secondviewcontroller Alloc]init];
Navigation bar Uinavigationcontroller *navigc=[[uinavigationcontroller ALLOC]INITWITHROOTVIEWCONTROLLER:FIRSTVC]; [Email protected] "first";
[Email protected] "4";
[Email protected] "second";
[Email protected] "1";
Uitabbarcontroller *tabbarc=[[uitabbarcontroller Alloc]init];
[Tabbarc SETVIEWCONTROLLERS:@[NAVIGC,SECONDVC]];
Root view
Self.window.rootviewcontroller=tabbarc;
return YES;} 3. Click "4 (First)" and "1 (second)" In the view respectively to switch to the corresponding view.
iOS design multi-view navigation bar Uinavigationcontroller A simple design for switching views