标签:
UINavigationBar
UINavigationBar是一个负责View跳转的控件。在NavigationBar下面允许存在子View
有二种方式可以创建UINavigationBar
1. 代码篇
创建2个Controller,一个继承自ViewController
项目右键->NewFile->Cocoa Touch Class。
Subclass of:选择ViewController,创建一个ViewController
同样的方式在创建一个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;
}
标签:
原文地址:http://www.cnblogs.com/kfsmqoo/p/5390362.html