Latest 0.3
Homepage https://github.com/ezefranca/TabbarControllerHideable
License MIT
Platforms ios 8.0
Authors

A drop in UITabbarController with show and hide options

CI Status
Version
License
Platform

TabbarControllerHideable

Requirements

  • Xcode 8.0+
  • iOS 8.3+

Installation

CocoaPods

You can use CocoaPods to install TabbarControllerHideable by adding it to your Podfile:

use_frameworks!
pod 'TabbarControllerHideable'

Example

To run the example project, clone the repo, and run pod install from the Example directory first.

Usage example

To start the TabbarControllerHideable programmatically you can initialize like a normal UITabbarController


        let firstTab: UIViewController = UIViewController()
        let secondTab: UIViewController = UIViewController() 
        let tabs = NSArray(objects: firstTab, secondTab)

        let tabBarController = UITabBarHideableController()

        // Set ViewControllers
        tabBarController?.setViewControllers(tabs as? [UIViewController], animated: false)

To use the show / hide methods, yours controllers need the UITabbarItemHideable protocol and get the tabbar item programmatically using one of the protocols methods:

    func getTabbarItem(coder:NSCoder) -> UITabBarItem?
    func getTabbarItem(title: String?, image: UIImage?, tag: Int) -> UITabBarItem
    func getTabbarItem(title: String?, image: UIImage?, selectedImage: UIImage?) -> UITabBarItem
    func getTabbarItem(tabBarSystemItem systemItem: UITabBarSystemItem, tag: Int) -> UITabBarItem

import UIKit

class FirstViewController: UIViewController, UITabbarItemHideable {

    override func viewDidLoad() {
        super.viewDidLoad()
        self.tabBarItem = getTabbarItem(tabBarSystemItem: .featured, tag: 1)
        self.view.backgroundColor = UIColor.red
        let button = UIButton(frame: CGRect(x: self.view.center.x - 30, y: self.view.center.y - 30, width: 60, height: 60))
        button.backgroundColor = UIColor.white
        button.addTarget(self, action: #selector(hideTapped), for: .touchUpInside)
        self.view.addSubview(button)
    }

    func hideTapped() {
        if !(self.tabBarController as! UITabBarHideableController).isHidded {
            (self.tabBarController as! UITabBarHideableController).hideTabBar(animated: true, duration: 0.75)
        }
        else {
            (self.tabBarController as! UITabBarHideableController).showTabBar(animated: true)
        }
    }
}

class SecondViewController: UIViewController, UITabbarItemHideable {

    override func viewDidLoad() {
        super.viewDidLoad()
        self.tabBarItem = getTabbarItem(tabBarSystemItem: .search, tag: 2)
        self.view.backgroundColor = UIColor.blue

        let button = UIButton(frame: CGRect(x: self.view.center.x - 30, y: self.view.center.y - 30, width: 60, height: 60))
        button.backgroundColor = UIColor.white
        button.addTarget(self, action: #selector(hideTapped), for: .touchUpInside)
        self.view.addSubview(button)
    }

    func hideTapped() {
        if !(self.tabBarController as! UITabBarHideableController).isHidded {
            (self.tabBarController as! UITabBarHideableController).hideTabBar(animated: true)
        }
        else {
            (self.tabBarController as! UITabBarHideableController).showTabBar(animated: true, duration: 0.75)
        }
    }
}

Author

ezefranca, [email protected]

License

TabbarControllerHideable is available under the MIT license. See the LICENSE file for more info.

Latest podspec

{
    "name": "TabbarControllerHideable",
    "version": "0.3",
    "summary": "A UITabbarController replacement with show / hide options.",
    "description": "'A drop in UITabbarController replacement with show / hide options.'",
    "homepage": "https://github.com/ezefranca/TabbarControllerHideable",
    "license": {
        "type": "MIT",
        "file": "LICENSE"
    },
    "authors": {
        "ezefranca": "[email protected]"
    },
    "source": {
        "git": "https://github.com/ezefranca/TabbarControllerHideable.git",
        "tag": "0.3"
    },
    "platforms": {
        "ios": "8.0"
    },
    "source_files": "UITabBarHideableController/**/*",
    "pushed_with_swift_version": "3.0"
}

Pin It on Pinterest

Share This