Swiftpack.co - Package - emrepun/StickyTabBarViewController


Sticky and Collapsible View Controller on top of tab bar


  • iOS 10.0
  • Tab bar is visible as long as there is a sticky view controller allocated on top of it (any vc pushed at any point should not set hidesBottomBarWhenPushed to true.


StickyTabBarViewController is available through SPM and CocoaPods.

  • SPM Installation: Add it as a new package dependency with https://github.com/emrepun/StickyTabBarViewController.git

  • CocoaPods Installation:

Simply add the following line to your Podfile:

pod 'StickyTabBarViewController', '1.0.5'


Subclass StickyViewControllerSupportingTabBarController from your tab bar controller.

Configure animation duration or collapsed view height directly from your tabbar controller:

From viewDidLoad:

import UIKit
import StickyTabBarViewController

class MainTabBarController: StickyViewControllerSupportingTabBarController {

    override func viewDidLoad() {
        collapsedHeight = 50.0
        animationDuration = 0.5

By overriding initialisers of the tabbar controller:

override init(nibName nibNameOrNil: String?, bundle nibBundleOrNil: Bundle?) {
    super.init(nibName: nibNameOrNil, bundle: nibBundleOrNil)
    // here if you are using xib
    collapsedHeight = 50.0
    animationDuration = 0.5

required init?(coder: NSCoder) {
    super.init(coder: coder)
    // configure also on required init (if you are using storyboard for example)
    collapsedHeight = 50.0
    animationDuration = 0.5

Can also update it any time by accessing to tabBarController.

Presented View Controller Configurations:

Any view controller to have sticky behaviour must conform to Expandable and implement a minimisedView.

The implemented minimisedView should be ideally anchored on top of the view controller's view and its height (either by a direct height constraint or some other constraints) should be equal to the value of collapsedHeight. You don't need to worry about hiding or showing it since it is handled by StickyTabBarViewController itself.

var minimisedView: UIView {
    return UIView() // or return your outlet for minimised view.

Collapse sticky view from the view controller that conforms to Expandable as following:


Expand sticky view from the view controller that conforms to Expandable as following:


Remove sticky view from the view controller that conforms to Expandable as following:


Configure a Sticky child ViewController as following:

if let tabBarController = tabBarController as? StickyViewControllerSupportingTabBarController {
    let viewControllerToStick = SampleChildViewController()
                                               isFullScreenOnFirstAppearance: true)

Interaction with the presented sticky child view controller from anywhere with tabBarController access:

Access tabBarController to interact with sticky child view controller:

var tabController: StickyViewControllerSupportingTabBarController? {
    if let tabBarController = tabBarController as? StickyViewControllerSupportingTabBarController {
        return tabBarController
    return nil

Expand/collapse child view controller:


Pending Improvements:

  • It would be nice to have the ability to hide tab bar and status bar upon expanding, in parameterised way.
  • Right now it is not possible to configure or overwrite the implemented sticky VC, one must first remove it and then implement another if needed. Maybe implement overwriting if configure is called while there is already a view controller allocated?


Stars: 53


Used By

Total: 0


- 2020-06-04 21:21:41

0.0.3 - 2020-04-15 16:47:37

Few api changes,

For the child viewController that conforms to Expandable;

  • expander is renamed to container

Following methods are renamed: removeCollapsibleViewController(animated:) -> removeCollapsableChild(animated:) configureCollapsedTrainingView(withChildViewController:) -> configureCollapsableChild(:)

Deprecated following tabBarController methods:

  • updateCollapsedHeight(to:)
  • updateAnimationDuration(to:)

Now instead you can directly change these values by overriding init methods or in viewDidLoad, see README for more details.

Fixes force unwrapping. - 2020-03-29 23:30:20

Initial Release - 2020-03-29 23:25:41