Skip to content

This framework help you to give a better user experience to your user with smooth transition between TabBarItem

License

Notifications You must be signed in to change notification settings

shndrs/SwiftyTabBarTransition

Repository files navigation

SwiftyTabBarTransition

SwiftyTabBarTransition codebeat badge swift-version Version Platform License Carthage Compatible cocoapods release-date

Example

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

leftToRight scaleInXY

How to use

For enjoy this framework you have three simple steps:

Step 1

Let's import SwiftyTabBarTransition in top of your UITabBarController class first

import SwiftyTabBarTransition

Step 2

then in viewDidLoad() method of your UITabBarController, make delegate equal to self, pretty simple so far, right?! 😉

class TabBarController: UITabBarController {

    override func viewDidLoad() {
        super.viewDidLoad()
        delegate = self
    }
    
}

Step 3

your UITabBarController class, must inherite from UITabBarControllerDelegate protocol, so write an extension of your UITabBarController, then confirm from animationControllerForTransitionFrom method

extension TabBarController: UITabBarControllerDelegate {
    
    func tabBarController(_ tabBarController: UITabBarController, animationControllerForTransitionFrom fromVC: UIViewController, to toVC: UIViewController) -> UIViewControllerAnimatedTransitioning? {
        
        let transitionOptions = SwiftyTabBarTransitionOptions(duration: 0.3, animationOption: .bottomToTop)
        let transition = SwiftyTabBarTransition.set(transition: transitionOptions)
        return transition
    }
}

Create an object of SwiftyTabBarTransitionOptions. This class has 2 peroperties:

  • duration

Which is the duration of transition

  • animationOption

Which is the style of transition animation

Animation Option

It's an enum for changing transition animation

animationOption
.scaleX
.scaleY
.scaleInXY
.scaleOutXY
.rightToLeft
.leftToRight
.topToBottom
.bottomToTop
.fade
.topLeftToBottomRight
.bottomLeftToTopRight

More Animations

scaleX topLeftToBottomRight

Requirements

iOS 9.3+

Xcode 10.2.1

Swift 5

Installation

SwiftyTabBarTransition is available through CocoaPods. To install it in latest version, simply add the following line to your Podfile:

Swift 4.2

pod 'SwiftyTabBarTransition', '~> 1.0.2'

Swift 5.0

pod 'SwiftyTabBarTransition', '~> 1.5.3'

To get the latest version of library using Carthage, you can add following line to your Cartfile.

Swift 4.2

github "shndrs/SwiftyTabBarTransition" "1.0.2"

Swift 5.0

github "shndrs/SwiftyTabBarTransition" "1.5.3"

Author

[email protected], [email protected], shndrs

License

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