There are many ways to do what you asked. The easiest one being of course to just create it in the interface builder but I assume this is not what you had in mind. I created an example of the image you posted above. It's not exactly the same but you can play with the numerous properties to get the look and feel of what it is you are looking for.
First, place a segment in a toolbar. Place this toolbar right below the navigation bar. Set the delegate of the toolbar to your view controller, and return UIBarPositionTopAttached in positionForBar:. You can see in the store app, if you perform an interactive pop gesture, that the segment bar does not move the same as the navigation bar. That's because they are not the same bar.
Now to remove the hairline. The "hairline" is an UIImageView that is a subview of the navigation bar. You can find it and set it as hidden. This is what Apple does in their native calendar app, for example, as well as the store app. Remember to show it when the current view disappears. If you play a little with the Apple apps, you will see that the hairline is set to hidden on viewWillAppear: and set to shown in viewDidDisappear:.
To achieve the style of the search bar, just set the bar's searchBarStyle to UISearchBarStyleMinimal.
Now to remove the hairline. The "hairline" is an UIImageView that is a subview of the navigation bar. You can find it and set it as hidden. This is what Apple does in their native calendar app, for example, as well as the store app. Remember to show it when the current view disappears. If you play a little with the Apple apps, you will see that the hairline is set to hidden on viewWillAppear: and set to shown in viewDidDisappear:.
Another approach would be to look for the hairline and move it below the added toolbar. Here is what I came up with.
Apple has sample app specifically for this. It describes setting a transparent shadow image and colored background image for the navigation bar and how to configure a view below the navigation bar. It also has examples of other navigation bar customizations.
I tried removing the hairline using @Simon's method but it did not work. I'm probably doing something wrong because I am super noob. However, instead of removing the line, you can simply hide it using the hidden attribute. Here's the code:
var hairLine: UIView = UIView()
override func viewDidLoad() {
super.viewDidLoad()
doneButton.enabled = false
for parent in self.navigationController!.navigationBar.subviews {
for childView in parent.subviews {
if childView is UIImageView && childView.bounds.size.width == self.navigationController!.navigationBar.frame.size.width {
hairLine = childView
}
}
}
}
override func viewWillAppear(animated: Bool) {
hairLine.hidden = true
}
override func viewWillDisappear(animated: Bool) {
hairLine.hidden = false
}