Folding Tab Bar and Tab Bar Controller

Overview

FoldingTabBar.iOS

CocoaPods Compatible Carthage compatible

Folding Tab Bar and Tab Bar Controller

Inspired by this project on Dribbble

Also, read how it was done in our blog

Preview

Requirements

iOS 7.0

Installation

CocoaPods

pod 'FoldingTabBar', '~> 1.2.1'

Carthage

github "Yalantis/FoldingTabBar.iOS" ~> 1.2.1

Manual Installation

Alternatively you can directly add all the source files from FoldingTabBar folder to your project.

  1. Download the latest code version or add the repository as a git submodule to your git-tracked project.
  2. Open your project in Xcode, then drag and drop all the folder directories in FoldingTabBar folder onto your project (use the "Product Navigator view"). Make sure to select Copy items when asked if you extracted the code archive outside of your project.

Introduction

YALFoldingTabBarController

YALFoldingTabBarController is a subclass of UITabBarController with custom animating YALFoldingTabBar.

YALFoldingTabBar

YALFoldingTabBar is a subclass of a standard UIView. We wanted to make this component expand and contract in response to a user tapping. When the component is closed you can only see a central button (“+”). When tapping on it, our custom Tab Bar expands letting other tabBarItems appear, so that the user can switch the controllers.

Each separate tabBarItem can have two additional buttons on the left and right. These buttons can be used to let a user interact with a selected screen on the YALFoldingTabBarController without even having to leave it.

YALTabBarItem

YALTabBarItem is a model to configure your tab bar items with images.

Usage

Option 1: The simplest way is to use YALFoldingTabBarController as it is. You can also subclass it if you indend to change the default behaviour.

Option 2: You can write your own implementation of UITabBarController and use YALFoldingTabBar or its subclass.

Here is an instruction of how to use YALFoldingTabBarController in the Storyboard.

  1. Add native UITabBarController to the storyboard, establish relationships with its view controllers.
  2. Choose YALFoldingTabBarController as custom class for UITabBarController.
  3. Choose YALCustomHeightTabBar as custom class for UITabBar inside YALFoldingTabBarController
  4. In AppDelegate method take out an instance of YALFoldingTabBarController from the window.rootViewController and supply it with images for the left and right tabBarItems respectively. Also you can add your own image for the center button of YALFoldingTabBar.

Objective-C

    YALFoldingTabBarController *tabBarController = (YALFoldingTabBarController *) self.window.rootViewController;

    //prepare leftBarItems
    YALTabBarItem *item1 = [[YALTabBarItem alloc] initWithItemImage:[UIImage imageNamed:@"nearby_icon"]
                                                      leftItemImage:nil
                                                     rightItemImage:nil];
    
    
    YALTabBarItem *item2 = [[YALTabBarItem alloc] initWithItemImage:[UIImage imageNamed:@"profile_icon"]
                                                      leftItemImage:[UIImage imageNamed:@"edit_icon"]
                                                     rightItemImage:nil];
    
    tabBarController.leftBarItems = @[item1, item2];

    //prepare rightBarItems
    YALTabBarItem *item3 = [[YALTabBarItem alloc] initWithItemImage:[UIImage imageNamed:@"chats_icon"]
                                                      leftItemImage:[UIImage imageNamed:@"search_icon"]
                                                     rightItemImage:[UIImage imageNamed:@"new_chat_icon"]];
    
    
    YALTabBarItem *item4 = [[YALTabBarItem alloc] initWithItemImage:[UIImage imageNamed:@"settings_icon"]
                                                      leftItemImage:nil
                                                     rightItemImage:nil];
    tabBarController.rightBarItems = @[item3, item4];

Swift

    if let tabBarController = window?.rootViewController as? YALFoldingTabBarController {

        //leftBarItems

        let firstItem = YALTabBarItem(
            itemImage: UIImage(named: "nearby_icon")!,
            leftItemImage: nil,
            rightItemImage: nil
        )

        let secondItem = YALTabBarItem(
            itemImage: UIImage(named: "profile_icon")!,
            leftItemImage: UIImage(named: "edit_icon")!,
            rightItemImage: nil
        )

        tabBarController.leftBarItems = [firstItem, secondItem]

        //rightBarItems

        let thirdItem = YALTabBarItem(
            itemImage: UIImage(named: "chats_icon")!,
            leftItemImage: UIImage(named: "search_icon")!,
            rightItemImage: UIImage(named: "new_chat_icon")!
        )

        let forthItem = YALTabBarItem(
            itemImage: UIImage(named: "settings_icon")!,
            leftItemImage: nil,
            rightItemImage: nil
        )

        tabBarController.rightBarItems = [thirdItem, forthItem]
    }

If you want to handle touches on extra tabBarItems import YALTabBarDelegate protocol to the subclass of the proper UIVIewController and implement these methods: ##Objective-C

- (void)tabBarDidSelectExtraLeftItem:(YALFoldingTabBar *)tabBar;
- (void)tabBarDidSelectExtraRightItem:(YALFoldingTabBar *)tabBar;

Swift

func tabBarDidSelectExtraLeftItem(tabBar: YALFoldingTabBar!)
func tabBarDidSelectExtraRightItem(tabBar: YALFoldingTabBar!)

If you want to handle touches on tabBarItems by indexes import YALTabBarDelegate protocol to the subclass of the proper UIVIewController and implement these methods:

Objective-C

- (void)tabBar:(YALFoldingTabBar *)tabBar didSelectItemAtIndex:(NSUInteger)index;
- (BOOL)tabBar:(YALFoldingTabBar *)tabBar shouldSelectItemAtIndex:(NSUInteger)index;

Swift

func tabBar(tabBar: YALFoldingTabBar!, didSelectItemAtIndex index: UInt)
func tabBar(tabBar: YALFoldingTabBar!, shouldSelectItemAtIndex index: UInt) -> Bool

If you want to observe contracting and expanding animation states in YALFoldingTabBar the following methods of YALTabBarDelegate protocol can be implemented:

Objective-C

- (void)tabBarWillCollapse:(YALFoldingTabBar *)tabBar;
- (void)tabBarWillExpand:(YALFoldingTabBar *)tabBar;

- (void)tabBarDidCollapse:(YALFoldingTabBar *)tabBar;
- (void)tabBarDidExpand:(YALFoldingTabBar *)tabBar;

Swift

func tabBarWillCollapse(tabBar: YALFoldingTabBar!)
func tabBarWillExpand(tabBar: YALFoldingTabBar!)

func tabBarDidCollapse(tabBar: YALFoldingTabBar!)
func tabBarDidExpand(tabBar: YALFoldingTabBar!)

Important notes

Because we changed the height of the default UITabBar you should adjust your content to the bottom of viewcontroller's superview, and ignore Bottom Layout Guide. You should also uncheck 'Under bottom bars' '

You can see how we did it on the example project.

Tips for customization

You can make the following configurations for custom tabBar:

  1. Specify height

Objective-C

tabBarController.tabBarViewHeight = YALTabBarViewDefaultHeight;

Swift

tabBarController.tabBarViewHeight = YALTabBarViewDefaultHeight
  1. Specify insets and offsets

Objective-C

    tabBarController.tabBarView.tabBarViewEdgeInsets = YALTabBarViewHDefaultEdgeInsets;
    tabBarController.tabBarView.tabBarItemsEdgeInsets = YALTabBarViewItemsDefaultEdgeInsets;
    tabBarController.tabBarView.offsetForExtraTabBarItems = YALForExtraTabBarItemsDefaultOffset;

Swift

tabBarController.tabBarView.tabBarViewEdgeInsets = YALTabBarViewHDefaultEdgeInsets
tabBarController.tabBarView.tabBarItemsEdgeInsets = YALTabBarViewItemsDefaultEdgeInsets
tabBarController.tabBarView.offsetForExtraTabBarItems = YALForExtraTabBarItemsDefaultOffset
  1. Specify colors

Objective-C

    tabBarController.tabBarView.backgroundColor = [UIColor colorWithRed:94.0/255.0 green:91.0/255.0 blue:149.0/255.0 alpha:1];
    tabBarController.tabBarView.tabBarColor = [UIColor colorWithRed:72.0/255.0 green:211.0/255.0 blue:178.0/255.0 alpha:1];
    tabBarController.tabBarView.dotColor = [UIColor colorWithRed:94.0/255.0 green:91.0/255.0 blue:149.0/255.0 alpha:1];

Swift

tabBarController.tabBarView.backgroundColor = UIColor(
                                                  red: 94.0/255.0,
                                                  green: 91.0/255.0,
                                                  blue: 149.0/255.0,
                                                  alpha: 1
                                              )

tabBarController.tabBarView.tabBarColor = UIColor(
                                              red: 72.0/255.0,
                                              green: 211.0/255.0,
                                              blue: 178.0/255.0,
                                              alpha: 1
                                          )

tabBarController.tabBarView.dotColor = UIColor(
                                           red: 94.0/255.0,
                                           green: 91.0/255.0,
                                           blue: 149.0/255.0,
                                           alpha: 1
                                       )
  1. Specify height for additional left and right buttons

Objective-C

    tabBarController.tabBarView.extraTabBarItemHeight = YALExtraTabBarItemsDefaultHeight;

Swift

tabBarController.tabBarView.extraTabBarItemHeight = YALExtraTabBarItemsDefaultHeight

Let us know!

We’d be really happy if you sent us links to your projects where you use our component. Just send an email to [email protected] And do let us know if you have any questions or suggestion regarding the animation.

P.S. We’re going to publish more awesomeness wrapped in code and a tutorial on how to make UI for iOS (Android) better than better. Stay tuned!

License

The MIT License (MIT)

Copyright © 2017 Yalantis

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in
all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
THE SOFTWARE.
Comments
  • Tab Bar Extra Item and Main Button Change Color to Blue on UIalertviewController appearance

    Tab Bar Extra Item and Main Button Change Color to Blue on UIalertviewController appearance

    Whenever i open up a uialertcontroller the color of the middle button and extra buttons change to blue.

    I set the color in the app delegate and do not change it throughout the entire app so it's strange this is happening

    opened by imanodaysoffdotcom 11
  • How to use folding tab bar on none root view controller?

    How to use folding tab bar on none root view controller?

    Hello, how are you doing today? I'm trying to set YALFoldingTabBarController on specific view controller inside App Delegate, but it doesn't work (tab bar doesn't show up). It is possible to use this tab bar outside root view controller? How? Thanks!

    opened by MarceloPrado 9
  • Expand user intractable area underneath the tab bar

    Expand user intractable area underneath the tab bar

    Since there is now empty space in the area that the tab bar had previously occupied, it is possible to enable user interaction with the subviews of the view controller in these areas? For example, if a table view is extend to the bottom of the screen, is it possible to allow users to select cells all the way at the bottom of the screen? Thanks

    opened by avicooper1 9
  • The FoldingTabBar is not displayed when using performSegue

    The FoldingTabBar is not displayed when using performSegue

    When I perform a performSegue with code, for example in a login when redirecting to the login screen the tabs are not shown, only a black bar comes out; what is this about? simulator screen shot 26 01 2017 1 42 49 p m

    opened by resand 5
  • Expanding the clickable area

    Expanding the clickable area

    The TabBar Buttons can only be clicked by the center images. Sometimes it takes many invalid touches when trying to click the button. How to expand the clickable area?

    opened by TindleWei 5
  • Sample App and Integrated App crashes when entering foreground

    Sample App and Integrated App crashes when entering foreground

    App crashes when entering foreground. Works fine if i don't switch to any other view controllers but if i switch to a view controller other than the initial one presented it crashes when entering foreground from background. Never reaches the app delegate function "applicationWillEnterForeground(application: UIApplication)"

    Sample app provided crashes using FoldingTabBar Custom app crashes using FoldingTabBar

    Error Code: *** -[Not A Type CA_copyRenderValue]: message sent to deallocated instance 0x141241830

    Specs: Using version 'FoldingTabBar', '~> 1.0.7' Apple Swift version 2.2 (swiftlang-703.0.18.8 clang-703.0.31) I have the latest version of CocaoaPods - cocoapods-1.0.0 Swift Project with Bridging Header Iphone 6 Software Version 9.1

    image

    image

    opened by imanodaysoffdotcom 4
  • How to set Badge Value on TabBarItem

    How to set Badge Value on TabBarItem

    I have 4 items in my FoldingTabBarController but i want to set badge value to one of them which is at index 2. I can't understand how to do this? Can you please quote an Example?

    opened by syedqamara 4
  • Is it possible to change the background color of tabBar to transparent?

    Is it possible to change the background color of tabBar to transparent?

    trivial

    Under tabBar, the color is purple. Is it possible to change the purple background color to transparent that user can see content (in this case the pink color) under tabBar?

    opened by weinanfeng 4
  • TabBar disappears once I use a segue. TableView won't reload when using modal

    TabBar disappears once I use a segue. TableView won't reload when using modal

    I have VC1 with a tableview. Once I click the left tab bar button it goes to VC2 with a tableview using a segue, but once I click "back" button in VC2 using a segue the tab Bar disappears for VC1. Instead i used the [self dismissviewcontroller....] method and the VC1 comes up just fine with the tab bar except the tableview will not reload with the updated data from VC2. I already tried to place [tableview reloadData] in viewWillAppear method and it still is not working.

    How can I fix this issue?

    opened by LarryBrian 4
  • Error when Using Swift 3

    Error when Using Swift 3

    Hi guys,

    I've updated xcode to be the latest version which uses Swift 3.0. After I've converted all codes of my project and run it, I found out that "Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '-[_SwiftValue itemImage]: unrecognized selector sent to instance 0x600000056350'"

    So I've debugged to find which line of code caused errors and I found this line in the library.

    screen shot 2559-09-21 at 5 01 13 am

    Any Ideas to fix it???

    Thanks in advance.

    opened by robin43499 3
  • Update Left / Right Extra Buttons based on Action

    Update Left / Right Extra Buttons based on Action

    How would I proceed to say update (hide, change icon) of an Left / Right Extra button after a user has for example logged in the app... In case the user is logged out, I would like to hide the Logout button, while display it when the user is logged in... Thanks for your help

    opened by DonBaronFactory 3
  • unable to add the badge to tabbar item.

    unable to add the badge to tabbar item.

    The more information you provide, the faster we can help you.

    ⚠️ Select what you want - a feature request or report a bug. Please remove the section you aren't interested in.

    A feature request

    What do you want to add?

    Please describe what you want to add to the component.

    How should it look like?

    Please add images.

    Report a bug

    What did you do?

    Please replace this with what you did.

    What did you expect to happen?

    Please replace this with what you expected to happen.

    What happened instead?

    Please replace this with what happened instead.

    Your Environment

    • Version of the component: insert here
    • iOS version: insert here
    • Device: insert here
    • Xcode version: insert here
    • If you use Cocoapods: run pod env | pbcopy and insert here
    • If you use Carthage: run carthage version | pbcopy and insert here

    Project that demonstrates the bug

    Please add a link to a project we can download that reproduces the bug.

    opened by jaypanchal12 0
  • Get center and each item views for attaching showcase

    Get center and each item views for attaching showcase

    A feature request

    What do you want to add?

    I want to insert a showcase view on tabbar for teaching something to user. but I get center UIView and other items in any way

    A link to showcase

    MaterialShowcase-iOS

    priority: low status: queued type: enhancement 
    opened by hrsalehi 0
  • Issue with iPhone X

    Issue with iPhone X

    Hey, this might be an easy fix, how do I edit the height of the Circle TabView that when clicked expands? On iPhone X this is colliding with the virtual slider.

    Thanks

    priority: high status: queued type: bug 
    opened by twitteriosdevelopment 2
  • Setting title in view controller make title on tabbar appear

    Setting title in view controller make title on tabbar appear

    When I switch go from first tabbar controller to second title appears at the bottom.

    override func viewDidLoad() {
        super.viewDidLoad()
        
        self.title = "Timers"
        
        self.navigationItem.leftBarButtonItem = UIBarButtonItem.init(image: UIImage.init(named: "close"), style: UIBarButtonItemStyle.plain, target: self, action: #selector(closeDidTap))
    }
    

    http://joxi.net/52aNxWRs4N1ykA

    priority: medium status: queued type: bug 
    opened by molchanovskiy 0
Releases(1.2.1)
Owner
Yalantis
Knowledge is power and the way to get power is by sharing knowledge. We are open source because this is a smart way to live, work and play.
Yalantis
A custom tab bar controller for iOS.

ESTabBarController ESTabBarController is a custom tab bar controller for iOS. It has a tab indicator that moves animated along the bar when switching

null 122 Oct 6, 2022
A custom tab bar controller for iOS written in Swift 4.2

A custom tab bar controller for iOS written in Swift 4.0 Screenshots Installation Cocoa Pods: pod 'AZTabBar' Swift Package Manager: You can use The Sw

Antonio Zaitoun 335 Dec 11, 2022
Paging view controller and scroll tab view

TabPageViewController Description TabPageViewController is paging view controller and scroll tab view. Screenshot Infinity Mode Limited Mode Customiza

M 1.3k Jan 7, 2023
Different Styles of Custom Tab Bar

LightCardTabBar An expiremental project exploring different types of custom-tabbar styles, screenshots as below. Screenshots Implementation The implem

Hussein Ryalat 31 Dec 23, 2022
Simplistic & unfinished recreation of MobileSafari's tab bar

SafariTabBar This is a simplistic recreation of the MobileSafari tab bar on iPad (prior to iPadOS 15). It is also very unfinished, and not intended in

Steven Troughton-Smith 51 Oct 26, 2022
📱 TabBar – highly customizable tab bar for your SwiftUI application.

TabBar SwiftUI standard TabView component is not so flexible and to customize it you have to modify appearance proxy of UITabBar or implement your own

Tamerlan Satualdypov 162 Jan 5, 2023
Aesthetic floating tab bar ––– SwiftUI & Combine ⛓️ Importable via Swift Package Manager 📦

FloatingTabBar An aesthetic floating tab bar made with SwiftUI & Combine importabable via Swift Package Manager ?? Based off BottomBar-SwiftUI Preview

10011.co 135 Jan 8, 2023
A prototype of custom tab bar using SwiftUI with techniques of mask + matchedGeometryEffect

SliderTabBar A prototype of custom tab bar using SwiftUI with techniques of mask

Ka Kui 1 Dec 24, 2021
Another UITabBar & UITabBarController (iOS Tab Bar) replacement, but uses Auto Layout for arranging it's views hierarchy.

GGTabBar GGTabBar is a simple UITabBar & UITabBarController replacement that uses Auto Layout for constructing the GUI. I created it for curiosity, bu

Nicolas Goles 157 Sep 26, 2022
Emoji Tab Bar button badges ✨

SuperBadges Add emojis and colored dots as badges for your Tab Bar buttons ✨ Usage Add an emoji badge: YourTabBarController.addDotAtTabBarItemIndex(

Oded Harth 55 Dec 13, 2021
📱 A minimal tab bar alternative

MiniTabBar A clean simple alternative to the UITabBar. Only shows the title when being tapped on. Gives the app a way cleaner look :) Requirements iOS

Dylan Marriott 155 Dec 20, 2022
Aesthetic floating tab bar ––– SwiftUI & Combine ⛓️ Importable via Swift Package Manager 📦

FloatingTabBar An aesthetic floating tab bar made with SwiftUI & Combine importabable via Swift Package Manager ?? Based off BottomBar-SwiftUI Preview

10011.co 134 Jan 5, 2023
A flexible TabBarController with search tab like SNKRS.

PolioPager PolioPager is the easiest way to use PagerTabStrip including search tab in iOS. Written in pure swift. (日本語はこちら) Comparison SNKRS ↓↓↓↓ Poil

Yuiga Wada 176 Jan 7, 2023
iOS Top Tab Navigation

iOS-Top-Tab-Navigation Good news for all our users out there! Now there are no boundaries to your convenience, you can pass as much words as you want

MindInventory 14 Aug 3, 2022
A fully customizable container view controller to display a set of ViewControllers in a horizontal scroll view. Written in Swift.

DTPagerController This is a control for iOS written in Swift. DTPagerController is simple to use and easy to customize. Screenshots Default segmented

Tung Vo 290 Nov 13, 2022
™️ A powerful paging view controller with interactive indicator bars

⭐️ Features Easy to implement page view controller with interactive indicator bars. Highly adaptable and powerful customization. Fully extensible with

UI At Six 2.5k Jan 2, 2023
RAMAnimatedTabBarController is a Swift UI module library for adding animation to iOS tabbar items and icons. iOS library made by @Ramotion

ANIMATED TAB BAR Swift UI module library for adding animation to iOS tabbar items and icons.

Ramotion 11k Jan 8, 2023
Pager is the simplest and best way to implement sliding view controllers in Swift

Pager is the simplest and best way to implement sliding view controllers. Installation Drop in the Spring folder to your Xcode project. Or via CocoaPo

Lucas Oceano 234 Aug 5, 2022
A scroll pager that displays a list of tabs (segments) and manages paging between given views

ScrollPager A scroll pager similar to the one in Flipboard. The control creates a tabbar given a title or an image, and has the option of connecting t

Aryan Ghassemi 512 Aug 31, 2022