Giter VIP home page Giter VIP logo

foldingtabbar.ios's Introduction

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

pod 'FoldingTabBar', '~> 1.2.1'
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.

foldingtabbar.ios's People

Contributors

bearran avatar edbaev avatar grethi avatar hyerra avatar igormuzyka avatar maximletushov avatar mmrmmlrr avatar mrcompoteee avatar qiny avatar rnkyr avatar serejahh avatar vodolazkyi avatar wut2bsimple avatar yukitoto avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

foldingtabbar.ios's Issues

Only Two TabBar items

How would I set it for only two tab items and still get the '+' in the middle?

Like this:
img_3687

Circular Transistion Between TabBar Selections?

In your sample video/gif, when you tapped on one of the tab bar items, it looked like there was a circular or radial transition from the bottom of the screen. Is that part of this repository?

English Spelling Error in View's Header Files #naming issue

  • (void)tabBarViewDidCollapsed:(YALFoldingTabBar *)tabBarView;
  • (void)tabBarViewDidExpanded:(YALFoldingTabBar *)tabBarView;
  • (void)extraLeftItemDidPressedInTabBarView:(YALFoldingTabBar *)tabBarView;
  • (void)extraRightItemDidPressedInTabBarView:(YALFoldingTabBar *)tabBarView;

I think, it should be DidCollapse, instead of DidCollapsed, because there is "did" and we don't use -ed after "did."

Like, it is "applicationDidEnterBackgroound" and not "DidEnteredBackground."

Swift support

Is there a Swift version? Or are bridging headers needed?

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?

Collapse/Expand programmatically

I can't find a way to collapse or expand without a user interaction. Could be nice to do it right from YALFoldingTabBar.state setter

Xib or code example

I wonder:

  1. if it's possible to use this pod without storyboard, and just use code or xib

if 1) is true, is there any example else thx :)

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!

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

Make tab bar always expand

Hi there,

First of all, thanks for your hard working and share your work to the world.

How can I make your tab bar always expand?

Thanks

Using Swift

I'm having trouble getting this to work in my swift app. For some reason in the AppDelegate, it doesn't recognize YALFoldingTabBarController.

Controlling itemInTabBarViewPressed()

I would like to implement some functionality on the FoldingTabBar by using itemInTabBarViewPressed(). I would like to prevent the FoldingTabBar from switching ViewControllers while a network call is made. The index of the requested ViewController is stored, and when the network call completes, a callback is called that will switch to the requested ViewController.

I have tried to solve this issue, but have limited knowledge of Obj- C (I have learned iOS through Swift) and limited knowledge of the structure of FoldingTabBar. Any help implementing this functionality would be greatly appreciated.

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?

Hide tab bar

Hello,

I meet a problem of hiding tab bar. As seen in the image, the tab bar's titles are not hidden. Any suggestions?

screen shot 2016-01-20 at 06 12 09

Memory Leak

When I ran my app through the profiler it told me this
screen shot 2016-06-21 at 9 20 31 pm

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.

Swift update

Please update this to swift or create a tutorial on how to use it with swift!

TabBarView Datasource and Delegate

Hi,

Is it possible to rollback the 2 following properties in order to be able to use the TabBarView without the use of the TabBarController if not wanted ?

public class YALFoldingTabBar : UIView {
  @IBOutlet weak public var dataSource: YALTabBarDatasource!
  @IBOutlet weak public var delegate: YALTabBarDelegate!
  [...]
}

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

Carthage

Do you all have intentions for adding Carthage support? I'm currently migrating away from Cocoapods and would like to use your modules in Carthage. This would require the project to build as a framework.

How to hide the black dot

Hi all.

thanks to Yalantis about this excellent component.

if any one want to hide the black dot, this is the code that i use

YALFoldingTabBarController *tabBarController = (YALFoldingTabBarController *) self.window.rootViewController;
tabBarController.tabBarView.dotColor = [UIColor clearColor];

or you can implement the the protocol function

  • (void)tabBarViewDidExpand
    {
    YALFoldingTabBarController *tabBarController = (YALFoldingTabBarController *) [[UIApplication sharedApplication].delegate window].rootViewController;

    [tabBarController.tabBarView hideSelectedDotView];
    }

from inside any view controller

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?

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

Swift 2 example please

it was very difficult to follow the directions for swift implementation. Is it possible to provide a Swift example. Would be greatly appreciated  

TabBarViewController delegate

Hello!
How to call this method

  • (BOOL)tabBarController:(UITabBarController *)tabBarController shouldSelectViewController:(UIViewController *)viewController

    to trigger animations between controllers?

Swift implementation.

In the documentation(right here on github) that teaches on how to use it, Can you guys please also tell us how to use it with swift.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.