ESTabBarController is a highly customizable TabBarController component, which is inherited from UITabBarController.

Overview

ESTabBarController

SwiftPM compatible Carthage Compatible CocoaPods Swift v5 Twitter Twitter Chat Gitter.im

中文介绍

ESTabBarController is a highly customizable TabBarController component, which is inherited from UITabBarController.

Why?

In real-world development, we may encounter the situation that customizing the UITabBar. For instance: change font style, add animation, use bigger item. However it's hard to do with UITabBarItem.

With ESTabBarController, You can easily achieve these!

- Feature Description
1 Default style You can get system-like style by initializing the TabBar with ESTabBarController directly.

UITabBarController style:

System native style

ESTabBarController default style:

ES system-like style
2 Default style with "More" item If the items are more than the maximum number of displays, there will be a "More" item.

UITabBarController with "More":

enter image description here

ESTabBarController with "More":

enter image description here
3 Mix UITabBarItem and ESTabBarItem You can set any item as you want, including UITabBarItem and ESTabBarItem.

ESTabBar and UITabBar mixed style:

enter image description here

ESTabBar and UITabBar mixed style with "More":

enter image description here
4 UIKit attributes ESTabBarController is compatible with UITabBarController, UITabBar and UITabBarItem's most API attributes. You can migrate to ESTabBarController without any modification of the origin code.

Compatible with UITabBarController's selectedIndex:

enter image description here
5 Any nesting with UINavigationController Developing withUITabBarController, there are two common ways to handle layers:

First :

├── UITabBarController

└──── UINavigationController

└────── UIViewController

└──────── SubviewControllers

Second :

├── UINavigationController

└──── UITabBarController

└────── UIViewController

└──────── SubviewControllers

In the first case, need to set hidesBottomBarWhenPushed = true when pushing subViews. The second is not.

In ESTabBarController, add Container views to UITabBar to be compatible with these two ways。
6 Customizable style With ESTabBarController, you can:

1. Customize selected item's color and style:

enter image description here

2. Add selecting animation:

enter image description here

3. Customize item's background color:

enter image description here

4. Add highlight animation:

enter image description here

5. Add animation to prompt users:

enter image description here

6. And much more ...

7 Customizable item's size

Customizable click event
You can easily customize item's size using ESTabBarController.

When the button's frame is larger than TabBar, through the use of HitTest to achieve making outer TabBar area click valid.

In addition, ESTabBarController can customize click event, and through a block to callback super-layer to handle.

With big item in the middle of TabBar:

enter image description here

With a special hint style:

enter image description here

Customize click event:

enter image description here
8 Default notification style You can get system-like notification style by initializing the TabBar with ESTabBarController directly.

UITabBarController notification style:

enter image description here

ESTabBarController system-like notification style:

enter image description here
9 Customizable notification style With ESTabBarController, you can:

1. Customize notification animation:

enter image description here

enter image description here

2. Customize prompt style:

enter image description here

3. And much more ...

10 Lottie Through customizing ContentView, you are able to add Lottie's LAAnimationView to Item(s)

enter image description here

Requirements

  • Xcode 8 or later
  • iOS 8.0 or later
  • ARC
  • Swift 5 or later

Demo

You can download and build ESTabBarControllerExample project, and you will find more examples to use ESTabBarController, and also more examples to customize UITabBar。

Usage

CocoaPods

pod "ESTabBarController-swift"

Carthage

github "eggswift/ESTabBarController"

Manually

git clone https://github.com/eggswift/ESTabBarController.git
open ESTabBarController

TODO

  1. The Containers' layout is purely based on code,using Autolayout will be better.
  2. When there is "More", if edit it will occurs problem.
  3. Partial UITabBarItem attributes are not bridge to ESTabBarItem.
  4. The picture of 'More' item in ESTabBarItemMoreContentView is not set into framework, plan to convert it to CGBitmap.

Sponsor

You can support the project by checking out our sponsor page. It takes only one click:

git-ad
This advert was placed by GitAds

Acknowledgement

About

ESTabBarController is developed and maintained by Vincent Li. If you have any questions or issues in using ESTabBarController, welcome to issue.
If you want to contribute to ESTabBarController, Please submit Pull Request, I will deal with it as soon as possible.

Twitter URL Twitter Follow

License

The MIT License (MIT)

Copyright (c) 2013-2016 eggswift. All rights reserved.

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
  • Icons became very small after upgrading from 2.5 to 2.6.1

    Icons became very small after upgrading from 2.5 to 2.6.1

    Hi, I am using this library in my project and after updating from version 2.5 to 2.6.1 I've noticed that the tab icons size has changed and now they are very small. My tab bar design is image only. Each icon size is 40x40. I wanted to know if this change is by design or it's a bug?

    Thanks!

    opened by ranhsd 13
  • Error: Value of type 'UIAccessibilityTraits' (aka 'UInt64') has no member 'union' in

    Error: Value of type 'UIAccessibilityTraits' (aka 'UInt64') has no member 'union' in "internal extension ESTabBar"

    Greetings!

    Yesterday I did update my cocoapods and my project is no longer compile because of an error in ESTabBarController pod.

    The issue is pretty trivial and is related to container.accessibilityTraits access Could you please update the pod as we can't afford to do that because of CI flow integrated to our development cycle.

    Here are instructions of where the exact issue is:

    File: ESTabBar.swift Line 247: i**nternal extension ESTabBar /* Actions / {* Line 415: container.accessibilityTraits = container.accessibilityTraits.union(.selected) Error message: Value of type 'UIAccessibilityTraits' (aka 'UInt64') has no member 'union'

    Thank you in advance and hope for the quick fix as its really blocks us. Best Regards, Yegor

    opened by testest1 12
  • delegate to ESTabBarController, when user shouldSelect function will run 2 times

    delegate to ESTabBarController, when user shouldSelect function will run 2 times

    let tabController:ESTabBarController = ESTabBarController()
    tabController.delegate = self
    func tabBarController(_ tabBarController: UITabBarController, shouldSelect viewController: UIViewController) -> Bool {
            print("running")
            return true
        }
    
    stale 
    opened by aemoe 9
  •  Default first item animation issue

    Default first item animation issue

    If I set selectedIndex = 2 in viewDidLoad function of Tabbar Controller, when first open App , first item and third item will both show select animation. So if I want to just show third item animation.How can I do? Please help me, thanks!

    code:

     class CustomTabbarController: ESTabBarController {
        override func viewDidLoad() {
            super.viewDidLoad()
            
            if let tabBar = self.tabBar as? ESTabBar {
                tabBar.itemCustomPositioning = .fillIncludeSeparator
            }
            
            let v1 = UIViewController()
            let v1Nav = UINavigationController(rootViewController: v1)
            
            let v2 = UIViewController()
            let v2Nav = UINavigationController(rootViewController: v2)
            
            let v3 = UIViewController()
            let v3Nav = UINavigationController(rootViewController: v3)
            
            let v4 = UIViewController()
            let v4Nav = UINavigationController(rootViewController: v4)
            
            let v5 = UIViewController()
            let v5Nav = UINavigationController(rootViewController: v5)
            
            v1Nav.tabBarItem = ESTabBarItem.init(...)
            v2Nav.tabBarItem = ESTabBarItem.init(...)
            v3Nav.tabBarItem = ESTabBarItem.init(...)
            v4Nav.tabBarItem = ESTabBarItem.init(...)
            v5Nav.tabBarItem = ESTabBarItem.init(...)
            
            self.viewControllers = [v1Nav, v2Nav, v3Nav, v4Nav, v5Nav]
            
            selectedIndex = 2
        }
    }  
    
    class TabBarContentView: ESTabBarItemContentView {
    
        public var duration = 0.3
        override init(frame: CGRect) {
            super.init(frame: frame)
            highlightTextColor = UIColor.hex(hexStr: GREEN, alpha: 1)
            renderingMode = .alwaysOriginal
        }
        
        public required init?(coder aDecoder: NSCoder) {
            fatalError("init(coder:) has not been implemented")
        }
        
        override func selectAnimation(animated: Bool, completion: (() -> ())?) {
            self.bounceAnimation()
            completion?()
        }
        
        override func reselectAnimation(animated: Bool, completion: (() -> ())?) {
            self.bounceAnimation()
            completion?()
        }
        
        func bounceAnimation() {
            let impliesAnimation = CAKeyframeAnimation(keyPath: "transform.scale")
            impliesAnimation.values = [1.0 ,1.4, 0.9, 1.15, 0.95, 1.02, 1.0]
            impliesAnimation.duration = duration * 2
            impliesAnimation.calculationMode = kCAAnimationCubic
            imageView.layer.add(impliesAnimation, forKey: nil)
        }
    
    }
    
    
    opened by huaqixue 8
  • Update to support new style for UITabBar on iOS 11 for iPad (as well as iPhone landscape)

    Update to support new style for UITabBar on iOS 11 for iPad (as well as iPhone landscape)

    When an app is running on iPad (or iPhone landscape), the new behavior for UITabBar on iOS 11 is that the text appears to the right of the icon rather than below it. See attached screenshots of ESTabBarController sample app running on iOS 11 simulator, this is with the mixed style of ESTabBar and UITabBar:

    simulator screen shot - ipad pro 10 5-inch - 2017-08-07 at 14 37 52

    My proposal is that ESTabBarController exposes a property to specify whether you want the text below or to the right of the icons. Additionally, the default behavior should be to check what the OS version is and if it is 11 or greater than put the text to the right, otherwise put it below. What do you think @eggswift ?

    opened by rami-ihr 7
  • Why is there popToRootViewController?

    Why is there popToRootViewController?

    First thanks for this nice library.

    I see in your code that when same tab item is selected second time, you trigger a popToRootViewController. Why?

    https://github.com/eggswift/ESTabBarController/blob/master/Sources/ESTabBar.swift#L375

    And how can I disable this behaviour?

    Thank you.

    opened by benyboariu 7
  • Custom Image in Tab Bar Item

    Custom Image in Tab Bar Item

    I am trying to add custom image for the Tab Bar Item. Its not a greyscale Image. I have tried everything to add it through methods available in the library but couldn't add it.

    I have added subview to tabbar using this code.

    UIImage *imgPlaceAd = [UIImage imageNamed:@"placeAd-tab-bar"];
    UIImageView *imgTab = [[UIImageView alloc] initWithFrame:CGRectMake(self.tabBarController.tabBar.center.x - imgPlaceAd.size.width/2,
                                                        8.0,
                                                        imgPlaceAd.size.width,
                                                        imgPlaceAd.size.height)];
        
        imgTab.image = imgPlaceAd;
    
        [self.tabBarController.tabBar addSubview:imgTab];
    

    Doing that, it changes the Item's class and it is now UITabBarItem and not ESTabBarItem

    I have checked in the ESTabBar class and print the class in this function

    internal func select(itemAtIndex idx: Int, animated: Bool) 
    {....}
    

    When I try to add Image using the init function of ESTabBarItem I get a circularly grey image.

    PlaceAdView *placeAdVC = [[PlaceAdView alloc] init];
        
    placeAdVC.tabBarItem = [[ESTabBarItem alloc] init:[[TabBarBouncesContentView alloc] init] title:@"" image:[UIImage imageNamed:@"placeAd-tab-bar"] selectedImage:[UIImage imageNamed:@"placeAd-tab-bar"] tag:2];
    
    opened by taimur 6
  • Change item image and title size

    Change item image and title size

    Is there any way to change the size of the image and the size of the title name inside the ESTabbar...i have tried many ways but it doesnt work. Please reply ASAP.

    opened by imJithin777 5
  • removeFromParent 后 ESTabBar不见了

    removeFromParent 后 ESTabBar不见了

    ESTabBar --------| UINavigationViewController ---------------|MainViewController Push-------------| FirstViewController Present------| SecondViewController

    以上是我的层级结构 FirstViewController Present出一个模态窗口后, 我通过removeFromParentFirstViewController 移出导航栈, 之后在SecondViewController中dissmiss后 回到MainViewController后发现ESTabBar不见了, 但是重新push再返回就又有了.

    stale 
    opened by MQL9011 5
  • Issues with ShouldHijackHandler and DidHijackHandler

    Issues with ShouldHijackHandler and DidHijackHandler

    I subclassed ESTabBarController and having trouble with the HijackHandlers. I looked at the example project and I can't figure out what's going on.

    The hijack does fire correctly and run but the tab bar is switching viewControllers before it does that. I want it to stay on the same selected item.

    shouldHijackHandler = { _, _, index in if index == 4 { return true } return false } didHijackHandler = { [weak self] tabBarController, viewController,index in ... do stuff }

    This is the relevant Tab definition:

    var keyboardTabVC: KeyboardTabVC = { let keyboardTabVC = KeyboardTabVC() keyboardTabVC.tabBarItem = ESTabBarItem(TabBarBasicView(), title: nil, image: UIImage(named: "icKeyboard"), selectedImage: UIImage(named: "icKeyboardSelected")) return keyboardTabVC }()

    opened by pives 5
  • selectedImage not working

    selectedImage not working

    Hi, I'm trying to use the selectedImage argument when building my tabs, but when I selected the tab, the image doesn't change… is there something more to do?

    …
    let item = ESTabBarItem(TabBarContentView(), title: nil, image: UIImage(named: "UI Tab Home"),  selectedImage: UIImage(named: "UI Tab Home Selected"))
    …
    final class TabBarContentView: ESTabBarItemContentView {
    
        override init(frame: CGRect) {
            super.init(frame: frame)
            
            highlightIconColor = .red
            badgeOffset = UIOffset(horizontal: 6, vertical: -17)
            itemContentMode = .alwaysOriginal
        }
        
        required init?(coder aDecoder: NSCoder) {
            fatalError("init(coder:) has not been implemented")
        } 
    }
    …
    
    
    opened by jdanthinne 5
  • 现在会报这个警告

    现在会报这个警告

    Class ESTabBarController_swift.ESTabBar overrides the -traitCollection getter, which is not supported. If you're trying to override traits, you must use the appropriate API.

    opened by King9796 0
  • 使用图片自己的颜色

    使用图片自己的颜色

    /// Icon imageView renderingMode, default is .alwaysTemplate like UITabBarItem
    open var renderingMode: UIImage.RenderingMode = .alwaysTemplate {
        didSet {
            self.updateDisplay()
        }
    }
        renderingMode = .alwaysOriginal
    
    opened by howhyone 0
  • 模拟器运行错误

    模拟器运行错误

    Could not find module 'ESTabBarController_swift' for target 'x86_64-apple-ios-simulator'; found: arm64-apple-ios-simulator, at: /Users/libin/Library/Developer/Xcode/DerivedData/yizhuotong-genhuiwlzalkncaqxrzggabyuxsa/Build/Products/Debug-iphonesimulator/ESTabBarController-swift/ESTabBarController_swift.swiftmodule

    opened by bingolib 0
  • How do I fix ESTabBarController in iOS 15?

    How do I fix ESTabBarController in iOS 15?

    I just transitioned from iOS 13 to iOS 15 on Xcode 13 and the tab bar disappears on Table View scroll. When I scroll the table to the top the custom image of the tab bar goes away and it shows back when I scroll down. Is there any work around for that? Thanks.

    opened by barHopperSF 1
  • ESTabBarController 设置之后,默认没有itme高亮

    ESTabBarController 设置之后,默认没有itme高亮

    • 设置了两个,但是没有一个高亮
    func addChildViewController() {
        addChildViewController(vc: OverallViewController(), title: "天气预报", imageName: "weather")
        addChildViewController(vc: WeatherDetailViewController(), title: "当日情况", imageName: "detail")
        
        
    }
    
    func addChildViewController(vc: UIViewController, title: String, imageName: String) {
        //设置标题---由内至外设置的
        //设置图像
        //导航控制器
        vc.tabBarItem = ESTabBarItem(ESBouncesContentView(), title: title, image: UIImage(named: imageName), selectedImage: UIImage(named: imageName + "_sel"))
        let nav = ESNavigationController(rootViewController: vc)
        self.addChild(nav)
    }
    
    opened by mzx-699 0
Releases(2.9.0-spm)
  • 2.9.0-spm(Feb 3, 2022)

    What's Changed

    • fix typo in ExampleViewController textArray by @Keuha in https://github.com/eggswift/ESTabBarController/pull/187
    • fix Example projects compile error on Xcode 12.3 or above by @DayBySay in https://github.com/eggswift/ESTabBarController/pull/250

    New Contributors

    • @Keuha made their first contribution in https://github.com/eggswift/ESTabBarController/pull/187
    • @DayBySay made their first contribution in https://github.com/eggswift/ESTabBarController/pull/250

    Full Changelog: https://github.com/eggswift/ESTabBarController/compare/2.9.0...2.9.0-spm

    Source code(tar.gz)
    Source code(zip)
Owner
Vincent Li
Life is brief, and then you die, you know?
Vincent Li
A TabBarController with a unique animation for selection

BATabBarController Overview Recent Versions Language Version Swift 5 2.0.1 Swift 4 1.0.1 Obj C 0.1.6 The standard TabBarController is very limited in

Bryan Antigua 1.1k Dec 25, 2022
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
KYWheelTabController is a subclass of UITabBarController.It displays the circular menu instead of UITabBar.

KYWheelTabController KYWheelTabController is a subclass of UITabBarController.It displays the circular menu instead of UITabBar. Installation CocoaPod

kyo__hei 121 Oct 10, 2022
UITabBarController with swipe interaction between its tabs.

?? Features Zero setup Different animations Enable/Disable interactions easily Fluid gestures ?? Installation Using CocoaPods Edit your Podfile and sp

Marcos Griselli 1.4k Jan 7, 2023
ExpandedTabBar is a very creative designed solution for "more" items in UITabBarController

ExpandedTabBar is a very creative designed solution for "more" items in UITabBarController. It's greate experience to have more comfortable and intuitive UI.

Yervand Saribekyan, iOS Dev 256 Nov 1, 2022
A subclass of UITabBarController that translates UITabBarItems 1:1 into a Sidebar on iPadOS.

FredKitTabBarSplitView A subclass of UITabBarController that translates UITabBarItems 1:1 into a Sidebar on iPadOS. Simply use FredKitTabBarSplitView

Frederik Riedel 9 Jan 12, 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
:octocat: AdaptiveController is a 'Progressive Reduction' Swift UI module for adding custom states to Native or Custom iOS UI elements. Swift UI component by @Ramotion

ADAPTIVE TAB BAR 'Progressive Reduction' module for adding custom states to Native or Custom UI elements. We specialize in the designing and coding of

Ramotion 2k Nov 9, 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
TabDrawer is a customizable TabBar UI element that allows you to run a block of code upon TabBarItem selection

TabDrawer TabDrawer is a customizable TabBar UI element that allows you to run a block of code upon TabBarItem selection, or display a customizable dr

Winslow DiBona 503 Oct 5, 2022
Smooth customizable tabs for iOS apps.

SmoothTab Requirements iOS 11.0+ Swift 5.x Xcode 10+ Installation CocoaPods pod 'SmoothTab' How to use Complete screen To setup and customize the comp

Yervand Saribekyan, iOS Dev 105 Feb 13, 2022
Full Customizable Tabbar with IBInspectables

BEKCurveTabbar Full Customizable Tabbar with IBInspectables A fun replacement for UITabbar. The Component uses Bézier paths. Demo Example usage: You c

Behrad Kazemi 169 Dec 5, 2022
🐛 WormTabStrip ViewPager for iOS written in Swift, which gives continuous feedback to the user when scrolling

Worm Tab Strip Worm Tab Strip is inspired by android SmartTabStrip, android view pager like library for iOS written in swift. Basically it was build u

EzimetYusup 176 Dec 13, 2022
A custom ViewPager title strip which gives continuous feedback to the user when scrolling

SmartTabLayout A custom ViewPager title strip which gives continuous feedback to the user when scrolling. This library has been added some features an

ogaclejapan 7k Dec 30, 2022
This library is for adding animation to iOS tabbar items, which is inherited from UITabBarController.

This library is for adding animation to iOS tabbar items, which is inherited from UITabBarController. Installation Just add the Sources folder to your

Yuşa Doğru 162 Jan 6, 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
A TabBarController with a unique animation for selection

BATabBarController Overview Recent Versions Language Version Swift 5 2.0.1 Swift 4 1.0.1 Obj C 0.1.6 The standard TabBarController is very limited in

Bryan Antigua 1.1k Dec 25, 2022
Because Objective-C should have inherited more from Smalltalk

OpinionatedC Sometimes, Objective-C is just overly verbose. Life is too short to enumerateObjectsUsingBlock and who has the time to create sub-arrays

Leo Schweizer 52 Apr 7, 2022
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
KYWheelTabController is a subclass of UITabBarController.It displays the circular menu instead of UITabBar.

KYWheelTabController KYWheelTabController is a subclass of UITabBarController.It displays the circular menu instead of UITabBar. Installation CocoaPod

kyo__hei 121 Oct 10, 2022