Giter VIP home page Giter VIP logo

batabbarcontroller's Introduction

BATabBarController

CI Status Version License Platform

Overview

The standard TabBarController is very limited in terms of animations when you make a selection. This cocoapod allows you to use one with a sleek animation with customizable properties!


Requirements

  • iOS 8+ iPhone, iPad and iPod Touch devices

Example

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


Getting Started

Installation

BATabBarController is available through CocoaPods. To install it, simply add the following line to your Podfile:

pod "BATabBarController"

Usage

Default with No Text in Tab Bar

The example below create the default BATabBarController tab bar (default properties) without text.

UIViewController *vc1 = [[UIViewController alloc] init];
UIViewController *vc2 = [[UIViewController alloc] init];
UIViewController *vc3 = [[UIViewController alloc] init];

BATabBarItem *tabBarItem = [[BATabBarItem alloc] initWithImage:[UIImage imageNamed:@"icon1_unselected"]      
                                                 selectedImage:[UIImage imageNamed:@"icon1_selected"]];
BATabBarItem *tabBarItem2 = [[BATabBarItem alloc] initWithImage:[UIImage imageNamed:@"icon2_unselected"]      
                                                  selectedImage:[UIImage imageNamed:@"icon2_selected"]];
BATabBarItem *tabBarItem3 = [[BATabBarItem alloc] initWithImage:[UIImage imageNamed:@"icon3_unselected"]      
                                                  selectedImage:[UIImage imageNamed:@"icon1_selected"]];

BATabBarController *baTabBarController = [[BATabBarController alloc] init];
baTabBarController.viewControllers = @[vc1,vc2,vc3];
baTabBarController.tabBarItems = @[tabBarItem,tabBarItem2,tabBarItem3];                                                        baTabBarController.delegate = self;
[self.view addSubview:baTabBarController.view];

This creates the following:

Default with Text in Tab Bar

The example below create the default BATabBarController tab bar (default properties) with text.

UIViewController *vc1 = [[UIViewController alloc] init];
UIViewController *vc2 = [[UIViewController alloc] init];
UIViewController *vc3 = [[UIViewController alloc] init];

NSMutableAttributedString *option1 = [[NSMutableAttributedString alloc] initWithString:@"Option1"];
[option1 addAttribute:NSForegroundColorAttributeName value:[UIColor colorWithHex:0xF0F2F6] range:NSMakeRange(0,option1.length)];
BATabBarItem *tabBarItem = [[BATabBarItem alloc] initWithImage:[UIImage imageNamed:@"icon1_unselected"]    
                                                 selectedImage:[UIImage imageNamed:@"icon1_selected"]
                                                         title:option1];

NSMutableAttributedString *option2 = [[NSMutableAttributedString alloc] initWithString:@"Option2"];
[option2 addAttribute:NSForegroundColorAttributeName value:[UIColor colorWithHex:0xF0F2F6] range:NSMakeRange(0,option2.length)];
BATabBarItem *tabBarItem2 = [[BATabBarItem alloc] initWithImage:[UIImage imageNamed:@"icon2_unselected"]
                                                  selectedImage:[UIImage imageNamed:@"icon2_selected"]
                                                          title:option2];

NSMutableAttributedString * option3 = [[NSMutableAttributedString alloc] initWithString:@"Option3"];
[option3 addAttribute:NSForegroundColorAttributeName value:[UIColor colorWithHex:0xF0F2F6] range:NSMakeRange(0,option3.length)];
BATabBarItem *tabBarItem3 = [[BATabBarItem alloc] initWithImage:[UIImage imageNamed:@"icon3_unselected"]
                                                  selectedImage:[UIImage imageNamed:@"icon3_selected"]
                                                          title:option3];

BATabBarController *baTabBarController = [[BATabBarController alloc] init];
baTabBarController.viewControllers = @[vc1,vc2,vc3];
baTabBarController.tabBarItems = @[tabBarItem,tabBarItem2,tabBarItem3];                                                        baTabBarController.delegate = self;
[self.view addSubview:baTabBarController.view];

This creates the following:

##Methods ###Set Selected View Controller You can change the currently selected tab bar item programatically by using the method below. To avoid the animation pass false in the second parameter: setSelectedViewController:(UIViewController*)viewController animated:(BOOL)animated

BATabBarControllerDelegate

If you'd like to add external actions when a tab item is selected, you can use: tabBarController:(BATabBarController *)tabBarControllerdidSelectViewController:(UIViewController *)viewController

Properties

Tab Bar Color

To change the color of the tab bar, you can change the tabBarBackgroundColor property of the BATabBarController instance.

baTabBarController.tabBarBackgroundColor = [UIColor blackColor];

result:

Tab Bar Item Stroke Color

To change the color of the stroke in the animation, you can change the tabBarItemStrokeColor property of the BATabBarController instance.

baTabBarController.tabBarItemStrokeColor = [UIColor blueColor];

result:

Tab Bar Item Line Width

To change the size of the stroke in the animation, you can change the tabBarItemLineWidth property of the BATabBarController instance.

baTabBarController.tabBarItemLineWidth = 1.0;

result:

ChangeLog

Version 0.1.2 (06.21.2016)

  • Platform version supports 8.0+

Version 0.1.1 (05.20.2016)

  • Platform version supports 8.1+

Version 0.1.0 (05.18.2016)

  • Initial release

Further informations

  • N/A

Known issues

Author

Bryan Antigua, [email protected] - bryanantigua.com

License

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

batabbarcontroller's People

Watchers

 avatar

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.