GithubHelp home page GithubHelp logo

azfx / simpletab Goto Github PK

View Code? Open in Web Editor NEW
80.0 5.0 13.0 2.62 MB

A Simple iOS Tab Bar Controller with animation support.

License: MIT License

Ruby 2.42% Objective-C 1.68% Shell 30.43% Swift 65.48%
tab-switching animations uitabbarcontroller interface-builder transition

simpletab's Introduction

image

CI Status Version License Platform

About

. .
image image

SimpleTab provides an easy alternative to the default UITabBarController with following support :

  • Custom UI for Tab Bar Item
  • Custom Tab Bar Item Animations on Tab Switching
  • Custom View Transitions on Tab Switching

SimpleTab is developed with following principles :

  • Simple - Easy to use and revert
  • Keep the wheel - Utilize core features of UITabBarController
  • Flexible - Provide hooks to customize UI and Animations

Note: At the moment, SimpleTab does not work when instantiated programmatically. It must be used along with UITabBarController set in Interface Builder.

Demo

The included example project demonstrates the usage of SimpleTab

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

Requirements

  • iOS 8.0+
  • ARC

Installation

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

pod "SimpleTab"

Note: SimpleTab now supports Swift 3.X starting 0.2.0 version.

Getting Started

1.0 Import SimpleTab Framework to your Project

#import SimpleTab

2.0 Using Interface Builder, ensure :

  • Tab Bar Controller is set as SimpleTabBarController
  • Tab Bar is set as SimpleTabBar
  • Tab Bar Item is set as SimpleTabBarITem

3.0 Get Handle to Tab Bar Controller, preferably in AppDelegate

simpleTBC = self.window!.rootViewController as? SimpleTabBarController

4.0 Set View Transition

Included Animations

  • PopViewTransition
  • CrossFadeTransition
simpleTBC?.viewTransition = PopViewTransition()

5.0 Set Tab Bar Style

Included Styles

  • PopTabBarStyle
  • ElegantTabBarStyle
var style:SimpleTabBarStyle = PopTabBarStyle(tabBar: simpleTBC!.tabBar)

5.1 Optional - Set Tab Title attributes for selected and unselected (normal) states.
Or use Tint Color in the Interface Builder to set the states

style.setTitleTextAttributes([NSFontAttributeName : UIFont.systemFontOfSize(14),  NSForegroundColorAttributeName: UIColor.lightGrayColor()], forState: .Normal)
style.setTitleTextAttributes([NSFontAttributeName : UIFont.systemFontOfSize(14),NSForegroundColorAttributeName: colorWithHexString("4CB6BE")], forState: .Selected)

5.2 Optional - Set Tab Icon colors for selected and unselected (normal) states.
Or use the App tint color to set the states

style.setIconColor(UIColor.lightGrayColor(), forState: UIControlState.Normal)
style.setIconColor(UIColor.blueColor(), forState: UIControlState.Selected)

6.0 And finally, let Tab Bar Controller know of the style in use

simpleTBC?.tabBarStyle = style

Customizations

Refer customizations

Author

azfx, [email protected]

License

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

simpletab's People

Contributors

azfx 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

Watchers

 avatar  avatar  avatar  avatar  avatar

simpletab's Issues

crashes when used programatically

`
func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplicationLaunchOptionsKey: Any]?) -> Bool {

    let mainTBC = SimpleTabBarController()
    mainTBC.tabBar = SimpleTabBar()
    mainTBC.viewTransition = PopViewTransition()
    
    let style:SimpleTabBarStyle = PopTabBarStyle(tabBar: mainTBC.tabBar)
    style.setIconColor(color: .lightGray, forState: .normal)
    style.setIconColor(color: .blue, forState: .selected)
    
    mainTBC.tabBarStyle = style
    mainTBC.viewControllers = buildNavigationControllers()
    window?.rootViewController = mainTBC
    return true
}



func buildNavigationControllers()->[UINavigationController]{
    

    let testVC = UIViewController()
    testVC.title = "Test"
    let testNC = UINavigationController()
    testNC.navigationBar.isTranslucent = false
    testNC.viewControllers = [networkVC]
    testNC.tabBarItem = SimpleTabBarItem(title: "Test",
                                     image: UIImage(named:"icon_favorites") ,
                                     selectedImage: UIImage(named:"icon_favorites"))
    
    
    let lastVC = UIViewController()
    lastVC.title = "Test"
    let lastNC = UINavigationController()
    lastNC.navigationBar.isTranslucent = false
    lastNC.viewControllers = [networkVC]
    lastNC.tabBarItem = SimpleTabBarItem(title: "Test",
                                     image: UIImage(named:"icon_favorites") ,
                                     selectedImage: UIImage(named:"icon_favorites"))
    
    return [testNC,lastNC]
    
}`

screen shot 2017-03-28 at 1 03 27 pm

toBarItem's animation failed

Hi,
I have a problem with this.
When I move to a bar item, its position doesn't change. Shouldn't it go downward?

iconTopOffset and titleBottomOffset not working

I've tried everything I can think of, including manually setting the imageInsets but that didn't affect anything. I have everything setup in a storyboard, but it shouldn't matter. The TabBar items in the storyboard are SimpletabBarItems so the iconTopOffset and titleBottomOffset should work. My goal is to center the icon a little bit more and remove the title.

swift 4.2

Im trying to use with swift 4.2, but i having problens with absoleted functions
can you release a new atty ?
sorry for my inglish, Im from Brasil

Support for Iphone X

Would like to know if there is planned support for iPhone X in the future, since all constraints and other visuals break when building for iPhone X.
screen shot 2017-12-05 at 7 26 58 pm

PS. Thank you for this great library.

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.