AnimationSwitchingTabBar 1.0.0

AnimationSwitchingTabBar 1.0.0

Maintained by yysskk.



  • By
  • K.S.Rogers

AnimationSwitchingTabBar

Version Cocoapods Carthage compatible License Platform

Overview

AnimationSwitchingTabBar is an animatable tab bar class in Swift. This project is inspired by the dribble project.

alt text

Usage

Basic

Define a tab view controller

Inherit AnimationSwitchingTabBarController . And set child view controllers.

class TabViewController: AnimationSwitchingTabBarController {
    override func viewDidLoad() {
        super.viewDidLoad()
        
        let vc1: AnimationSwitchingViewController = ...
        let vc2: AnimationSwitchingViewController = ...
        let vc3: AnimationSwitchingViewController = ...
        setViewControllers([vc1, vc2, vc3])
    }
}

Define child view controllers

Inherit AnimationSwitchingViewController . And set an icon image.

class Child1ViewController: AnimationSwitchingViewController {
    override func viewDidLoad() {
        super.viewDidLoad()
        setIcon(image: UIImage(named: "SearchIcon"))
    }
}

Implement delegate

extension TabViewController: AnimationSwitchingTabBarControllerDelegate {
    override func tabBarController(_ tabBarController: AnimationSwitchingTabBarController,
                                   shouldSelect viewController: UIViewController) -> Bool {
        return true
    }

    override func tabBarController(_ tabBarController: AnimationSwitchingTabBarController, 
                                   didSelect viewController: UIViewController) {
        // Called when an tab bar controller selected the child view controller.
    }
}

Others

Set animatable icon

Define custom item class. And, configure constraints and an animation.

class CustomAnimatableItem: AnimationSwitchingTabBarItem {
    override func animate() {
        super.animate()
        // Define the item's animation to start.
    }
    
    override func setNotSelectedItem() {
        super.setNotSelectedItem()
        // Define constraints if the item is not selected.
    }
    
    override func setSelectedItem() {
        super.setNotSelectedItem()
        // Define constraints if the item is selected.
    }
}

Requirements

  • Swift 4.2 ~
  • Xcode 10.x ~

Installation

CocoaPods

AnimationSwitchingTabBar will be available through CocoaPods. To install it, simply add the following line to your Podfile:

pod 'AnimationSwitchingTabBar'

Carthage

You can integrate via Carthage, too. Add the following line to your Cartfile :

github "ks-rogers/AnimationSwitchingTabBar"

and run carthage update

Author

This framework was created by K.S.Rogers

License

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