首先设置Navigationbar为hidden:
self.navigationController.navigationBarHidden = YES;
然后创建NavBar:
UINavigationBar *mainNavBar = [[UINavigationBar alloc] initWithFrame:CGRectMake(0, offsetY, self.view.bounds.size.width, 44.f)];[mainNavBar useCustomNavigationBarWithColor:[UIColor titleBlueColor]];[self.view addSubview:mainNavBar];