UINavigationBar

UINavigationBar

UINavigationBar是一个负责View跳转的控件。在NavigationBar下面允许存在子View

屏幕快照 2016 04 14 上午11 03 16


有二种方式可以创建UINavigationBar


1. 代码篇
创建2个Controller,一个继承自ViewController

项目右键->NewFile->Cocoa Touch Class。

屏幕快照 2016 04 14 上午11 11 19

Subclass of:选择ViewController,创建一个ViewController

 屏幕快照 2016 04 14 上午11 12 58


同样的方式在创建一个Controller
Subclass of:UINavigationController


我们在项目代码的AppDelegate.m文件中加入如下代码:

- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {

    // Override point for customization after application launch.

    //创建一个UIViewController

    UIViewController* vcontroller = [[UIViewControlleralloc]initWithNibName:nilbundle:nil];

    

    //创建一个NavigationController 包含一个viewController

    MyNavigationController* myncontroller = [[MyNavigationControlleralloc]initWithRootViewController:vcontroller];

    

    //window大小根据系统的硬件来

    self.window = [[UIWindowalloc]initWithFrame:[[UIScreenmainScreen] bounds]];

    

    self.window.rootViewController = myncontroller;

    

    self.window.backgroundColor = [UIColorredColor];

    

    [self.windowmakeKeyAndVisible];

 

    returnYES;

}




posted @ 2016-04-14 11:21  kfsmqoo  阅读(212)  评论(0编辑  收藏  举报