//UINavigationController使用方法:
//1.初始化:
//使用时需要一个图控制器来做为UINavigationController根视视图控制器,本例中为TestViewController:
UINavigationController *nav = [[UINavigationController alloc] initWithRootViewController:[[TestViewController alloc] init]];
[window addSubview:nav.view];
#define COOKBOOK_PURPLE_COLOR [UIColor colorWithRed:0.20392f green:0.19607f blue:0.61176f alpha:1.0f]
#define BARBUTTON(TITLE, SELECTOR) [[[UIBarButtonItem alloc] initWithTitle:TITLE style:UIBarButtonItemStylePlain target:self action:SELECTOR] autorelease]
//若一个视图控制器在栈中,则可以调用navigationController和navigationItem来获得导航控制器或项目
//2.在TestViewController的viewDidLoad函数中,可以对导航条属性进行设置:
self.navigationController.navigationBar.tintColor = COOKBOOK_PURPLE_COLOR;
self.navigationItem.rightBarButtonItem = BARBUTTON(@"Flip", @selector(flip:));
// Set up the segmented control for picking the animation direction
UISegmentedControl *seg = [[[UISegmentedControl alloc] initWithItems:[@"Left Right" componentsSeparatedByString:@" "]] autorelease];
seg.selectedSegmentIndex = 0;
seg.segmentedControlStyle = UISegmentedControlStyleBar;
self.navigationItem.titleView = seg;