A Tab bar at arbitrary position similar to Home of Instagram, in Swift

To clarify I am not looking for a tab bar on top. I am wondering if there's a solution using what already exists to create something like a TabHost/ViewPager in Android for iOS in Swift; i.e, the bar could be moved and would control a section of the screen (similar to fragments in Android). There are lots of questions offering partial solutions such as this and this mostly showing how to place tab bar on top.

Also I know containerView is supposed to be used to contain a view as part of the screen; however, managing all the communication between views is not a simple task and is error-prone. Below is a simple storyboard showing such a design.

I am wondering if there's a more efficient way to achieve a functionality similar to the tab bar in Instagram's home which is somewhat in the middle of the screen? Thanks for your input.


In terms of a movable tab-bar, there's nothing out of the box as per the UIKit. You could possibly find something on https://www.cocoacontrols.com or similar sites which might fit the bill.

Failing that, you'd have to create a custom UIView to handle this.

In terms of handling the slit views e.g. top and bottom, it'd probably be better subclassing UIViewController and have that handle two container views as you have shown in your image.

As to communicating between viewControllers, it's not error prone in the slightest. You either use the responder chain to pass messages up the chain, create or use references between one another e.g. self.parentViewController or self.presentingViewController and in more complex ways let myViewController = self.presentingViewController!.childViewControllers[0] as? MyViewControllerClass

Need Your Help

Creating RoundImageView causes NullPointerException


I want to create RoundedImageView for some ImageView used in my app. I am creating custom view for that.

Swift: thread-safe counter in a serial queue

ios multithreading swift atomic

I'm working async queued processes and I need to update a counter to keep track of the progress.