iOS design multi-view navigation bar Uinavigationcontroller simple design for switching views

Source: Internet
Author: User

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

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.