1.躲藏特定UIViewController的导航栏,在该视图控制器中参加代码:
- (void) viewDidAppear:(BOOL)animated
{
    [super viewDidAppear:animated];
    [self.navigationController setNavigationBarHidden:YES animated:YES];
}
- (void) viewDidDisappear:(BOOL)animated
{
    [super viewDidDisappear:animated];
    [self.navigationController setNavigationBarHidden:NO animated:YES];
}
2.初始化,一直为
[[UINavigationController alloc] initWithRootViewController:[[UIViewController alloc] init]]
3.定制自己的UINavigationController,是的push和present的方法变成自己想要的方法,以便一致处理视图特效
头文件:CustomNavigationController.h
@interface CustomNavigationController : UINavigationController
- (UIBarButtonItem *)navBarItemWithTarget:(id)target
                                   action:(SEL)action
                                imageName:(NSString*)imgName;
@end
完成文件: CustomNavigationController.m
//
//  CustomNavigationController.m
//  PudongTravel
//
//  Created by duwei on 14-4-23.
//  Copyright (c) 2014年 mark. All rights reserved.
//

#import "CustomNavigationController.h"
#import "AppDelegate.h"

@interface CustomNavigationController ()

@end

@implementation CustomNavigationController

- (id)initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil
{
    self = [super initWithNibName:nibNameOrNil bundle:nibBundleOrNil];
    if (self) {
        // Custom initialization
    }
    return self;
}

- (void)viewDidLoad
{
    [super viewDidLoad];
}

- (void)didReceiveMemoryWarning
{
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

- (void)navigationItemInit:(UIViewController*)viewController
{
    UILabel* titleLabel = [[UILabel alloc] initWithFrame:CGRectMake(0,40,175,44)];
    titleLabel.backgroundColor = [UIColor clearColor];  //设置Label布景通明
    titleLabel.font            = [UIFont boldSystemFontOfSize:16];  //设置文本字体与巨细
    titleLabel.textColor       = [UIColor whiteColor];  //设置文本色彩
    titleLabel.textAlignment   = NSTextAlignmentLeft;
    viewController.navigationItem.titleView = titleLabel;
}

- (UIBarButtonItem *)navBarItemWithTarget:(id)target
                                   action:(SEL)action
                                imageName:(NSString*)imgName
{
    UIButton *leftbutton = [UIButton buttonWithType:UIButtonTypeCustom];
    leftbutton.frame = CGRectMake(10, 4, 42, 40);
    [leftbutton setBackgroundImage:[UIImage imageNamed:imgName] forState:UIControlStateNormal];
    [leftbutton addTarget:target action:action forControlEvents:UIControlEventTouchUpInside];
    
    UIBarButtonItem *letfBarItem = [[UIBarButtonItem alloc] initWithCustomView:leftbutton];
    return letfBarItem;
}

- (void)backBtnPressed:(id)sender
{
    [super popViewControllerAnimated:YES];
}

- (void)dismissLeftBtnPress:(id)sender
{
    [super dismissViewControllerAnimated:YES completion:nil];
}

- (void)rightBtnPressed:(id)sender
{
    
}
#pragma mark - presentViewController && pushViewController method
- (void)presentViewController:(UIViewController *)viewControllerToPresent animated:(BOOL)flag
                   completion:(void (^)(void))completion
{
    [super presentViewController:viewControllerToPresent animated:flag completion:completion];
    // 增加回来
    UINavigationController *nav = (UINavigationController*)viewControllerToPresent;
    if ([self.viewControllers count] > 1){
        if (nav.topViewController.navigationItem.leftBarButtonItem == nil){
            nav.topViewController.navigationItem.leftBarButtonItem =
            [self navBarItemWithTarget:self
                                action:@selector(dismissLeftBtnPress:)
                             imageName:@"icon_return.png"];
        }
        if (nav.topViewController.navigationItem.rightBarButtonItem == nil)
        {
            nav.topViewController.navigationItem.rightBarButtonItem = [self navBarItemWithTarget:self action:@selector(rightBtnPressed:) imageName:@"icon_personal.png"];
        }
        [self navigationItemInit:nav.topViewController];
        [self navigationItemInit:nav.topViewController];
    }
}

- (void)pushViewController:(UIViewController *)viewController animated:(BOOL)animated
{
    [super pushViewController:viewController animated:animated];
    
    // 增加回来
    if ([self.viewControllers count] > 1){
        if (viewController.navigationItem.leftBarButtonItem == nil){
            viewController.navigationItem.leftBarButtonItem =
            [self navBarItemWithTarget:self
                                action:@selector(backBtnPressed:)
                             imageName:@"icon_return.png"];
        }
        if (viewController.navigationItem.rightBarButtonItem == nil)
        {
            viewController.navigationItem.rightBarButtonItem =
            [self navBarItemWithTarget:self
                                action:@selector(rightBtnPressed:)
                             imageName:@"icon_personal.png"];
        }

        [self navigationItemInit:viewController];
    }
}

@end
转载请注明出处:http://www.fometaux.com/TianShiDeBaiGu/