eshwavin / SETabView

SETabView is a TabBar with simple yet beautiful animations that makes your apps look cool!
MIT License
70 stars 5 forks source link
cocoapods custom-tabbar-controller ios setabview swift swift-package-manager swift5

CI Status Version License Platform

Animations

.holeBall1 .holeBall2 .holeBall3

What's New?

The API has been changed to resemble UITabBarController

Bug fixes

A whole lot of performance optimizations have been added so that our library does not slow down your app. Hurray!

Requirements

Integration

CocoaPods

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

pod 'SETabView'

In case the latest version (2.0.0) is not the one being installed, update the pod.

pod update 'SETabView'

Swift Package Manager

The Swift Package Manager is a tool for automating the distribution of Swift code and is integrated into the swift compiler.

Once you have your Swift package set up, adding SETabView as a dependency is as easy as adding it to the dependencies value of your Package.swift.

dependencies: [
.package(url: "https://github.com/eshwavin/SETabView.git", .upToNextMajor(from: "2.0.0"))
]

Directly include source files

Download and add the files in the Source folder directly into your Xcode Project. In this case you should skip

import SETabView

in the usage instructions.

Usage and Customization

Import SETabView into the parent view controller and any child view controllers

import SETabView

Inherit from the SETabViewController class in your tab view controller

class MyCustomTabViewController: SETabViewController {

   override func viewDidLoad() {
    super.viewDidLoad()

  }
}

Setting the view controllers and colors

Set the view controllers using setViewControllers(_:) method or by directly setting the viewControllers property

Customise the look by calling setTabColors(backgroundColor:ballColor:tintColor:unselectedItemTintColor:barTintColor:) method or simply setting the respective colors

class ViewController: SEViewController {

    override func viewDidLoad() {
      super.viewDidLoad()

      // set tab bar look collectively
      setTabColors(backgroundColor: UIColor.white, ballColor: UIColor.white, tintColor: UIColor.black, unselectedItemTintColor: UIColor.red, barTintColor: .clear)

      // set animation type
      animationType = .holeball3

      // set the view controllers
      setViewControllers(getViewControllers())

    }

    private func getViewControllers() -> [UIViewController] {
        let storyboard = UIStoryboard(name: "Main", bundle: nil)

        return [
            storyboard.instantiateViewController(withIdentifier: "firstVC"),
            storyboard.instantiateViewController(withIdentifier: "secondVC"),
            storyboard.instantiateViewController(withIdentifier: "thirdVC"),
            storyboard.instantiateViewController(withIdentifier: "fourthVC"),
            storyboard.instantiateViewController(withIdentifier: "fifthVC")
        ]
    }   
}

Providing the image for the tab bar

The child view controllers can conform to the SETabItemProvider protocol. Using seTabImage return a UITabBarItem for the view controller.

Alternatively you can set the tabBarItem property for the view controllers as you would do when using UITabBarController

class FirstViewController: UIViewController, SETabItemProvider {

    var seTabBarItem: UITabBarItem? {
        return UITabBarItem(title: "", image: UIImage(named: "first"), tag: 0)
    }

    override func viewDidLoad() {
        super.viewDidLoad()
    }
}

Setting the selected index programmatically

selectedTabIndex = 3

Restrictions

Example

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

Planned Improvements

Author

Srivinayak Chaitanya Eshwa, eshwavin@gmail.com

License

SETabView is available under the MIT license. See the LICENSE file for more info. SETabView uses the complete OrderedCollections code from swift-collections

Acknowledgement

Animation Inspiration

Icons