if u want perfectly look like your images that u are posted in the previous question, then u can do like below,
[self.navigationController.navigationBar setTranslucent:NO];
[self.navigationController.navigationBar setBackgroundImage:[UIImage new] forBarMetrics:UIBarMetricsDefault];
[self.navigationController.navigationBar setBarStyle:UIBarStyleBlack];
[self.navigationController.navigationBar setBarTintColor:[UIColor redColor]];
[self.navigationController.navigationBar setShadowImage:[UIImage new]];
UISearchBar *searchBar = [[UISearchBar alloc] init];
searchBar.placeholder = @"search";
self.title = @"Locations";
searchBar.frame = CGRectMake(0, 0, self.navigationController.view.bounds.size.width, 64);
searchBar.barStyle = UIBarStyleDefault;
[searchBar setTranslucent:NO];
searchBar.barTintColor = [UIColor redColor];
searchBar.backgroundImage = [UIImage new];
[self.view addSubview:searchBar];
and the navigation bar looks like below and change the search bar to your requirement

swift code
navigationController?.navigationBar.isTranslucent = false
navigationController?.navigationBar.setBackgroundImage(UIImage(), for: .default)
navigationController?.navigationBar.barStyle = .black
navigationController?.navigationBar.barTintColor = UIColor.red
navigationController?.navigationBar.shadowImage = UIImage()
title = "Location";
let searchBar = UISearchBar()
searchBar.placeholder = "Search"
searchBar.frame = CGRect(x: 0, y: 0, width: (navigationController?.view.bounds.size.width)!, height: 64)
searchBar.barStyle = .default
searchBar.isTranslucent = false
searchBar.barTintColor = UIColor.red
searchBar.backgroundImage = UIImage()
view.addSubview(searchBar)
story board setup:
every thing is fine, u just need to setup the story board view controller to embed in navigation controller
, (if u don't done yet), then in the view controller, just add a search bar and make outlet
for viewcontroller.swift
then do following changes
@IBOutlet weak var searchBar: UISearchBar!
override func viewDidLoad() {
super.viewDidLoad()
//navigationController?.navigationBar.isTranslucent = false //set it in strory board
navigationController?.navigationBar.setBackgroundImage(UIImage(), for: .default)
//navigationController?.navigationBar.barStyle = .black ////set it in strory board
//navigationController?.navigationBar.barTintColor = UIColor.red ////set it in strory board
navigationController?.navigationBar.shadowImage = UIImage()
title = "Location";
searchBar.barStyle = .default
searchBar.isTranslucent = false
searchBar.barTintColor = UIColor.red
searchBar.backgroundImage = UIImage()
}