UINavigationItem表示UINavigationBar中的控件

来源:互联网 发布:淘宝差评师哪里找 编辑:程序博客网 时间:2024/05/16 05:09

一般一个程序中有一个UIWindow,一个UINavigationController,一个根UIViewController,多个子UIViewController。

UIWindow是整个可视界面的容器,里面放置我们看到的UIView。
UIView负责处理屏幕上一个矩形区域的绘制,UIView中还可包含子UIView。
UIWindow是UIView类的扩展,可以看作是整个屏幕的根UIView。
UIViewController负责管理UIView的层次结构。可以有多个UIViewController。

一个UIViewController中有一个顶部的UINavigationBar、一个根UIView,多个子UIView。
UINavigationBar中有一个UINavigationItem,UINavigationItem。

UINavigationController是用于构建分层应用程序的主要工具,它维护了一个UIViewController栈。
这个栈中必须有一个根UIViewController,其他的UIViewController都是子UIViewController。

UINavigationItem表示UINavigationBar中的控件,比如左按钮、中间标题、右按钮。
UINavigationController会自动在当前子UIViewController的UINavigationBar左边添加一个返回按钮。
按钮名称是上一个UIViewController的标题。

在UIViewController中有访问view、bar的属性和方法
self.view.backgroundColor = [UIColor whiteColor]; //设置根UIView的颜色
self.navigationItem.title = @"title"; //设置UINavigationBar的标题
[self.navigationController popViewControllerAnimated:YES]; //弹出当前UIViewController

0 0
原创粉丝点击