GithubHelp home page GithubHelp logo

panevnyk / swipevc Goto Github PK

View Code? Open in Web Editor NEW
20.0 2.0 3.0 25.86 MB

Animated analog to UITabBarController, with cool interactive TabBar

License: MIT License

Objective-C 0.69% Swift 90.89% Ruby 8.43%
swift ios swipevc tabbar viewcontroller-transition animator items

swipevc's Introduction

SwipeVC

    

SwipeVC framework created as a cool animated analog to UITabBarController. SwipeVC gives you the possibility to manage screen not only using TabBar controls but simply sliding left and right.

You can add SVCTabBar with different animations to manage those screens. Also, you have the possibility to customize TabBar a lot. Adjust TabBar to top or bottom. Predefine insets by specific rules. Setup different Animators to image and title of the TabBarItem. Also, you can inject your own custom TabBar, TabBarItem, or specific Animator depends on what level of customization you need.

CocoaPods

For SwipeVC, use the following entry in your Podfile:

pod 'SwipeVC'

Then run pod install.

In any file you'd like to use SwipeVC in, don't forget to import the framework with import SwipeVC.

Usage

For use SVCSwipeViewController, you can simply extend you ViewController from SVCSwipeViewController. And add view controllers to viewControllers property.

final class ExampleSwipeViewController: SVCSwipeViewController {
    override func viewDidLoad() {
        super.viewDidLoad()
        addViewControllers()
    }

    private func addViewControllers() {
        let storyboard = UIStoryboard(name: "Main", bundle: nil)
        let firstViewController = storyboard.instantiateViewController(withIdentifier: "FirstViewController") as! FirstViewController
        let secondViewController = storyboard.instantiateViewController(withIdentifier: "SecondViewController") as! SecondViewController
        let thirdViewController = storyboard.instantiateViewController(withIdentifier: "ThirdViewController") as! ThirdViewController
        
        viewControllers = [firstViewController, secondViewController, thirdViewController]
    }
}

For use tabBar, you should inject tabBar property. You can use SVCTabBar or your custom realization. You can set tabBarType property (.top or . bottom) for change tab bar position in SVCSwipeViewController. SVCSwipeViewController have contentInsets, tabBarInsets, viewControllersInsets properties for customize some spaces in different way if you needed.

final class ExampleSwipeViewController: SVCSwipeViewController {
    override func viewDidLoad() {
        super.viewDidLoad()
        tabBarInjection()
    }

    private func tabBarInjection() {
        tabBarType = .top
        
        let defaultTabBar = SVCTabBar()
        
        // Init first item
        let firstItem = SVCTabItem(type: .system)
        firstItem.imageViewAnimators = [SVCTransitionAnimator(transitionOptions: .transitionFlipFromTop)]
        firstItem.setImage(UIImage(named: "ic_location_menu_normal")?.withRenderingMode(.alwaysOriginal), for: .normal)
        firstItem.setImage(UIImage(named: "ic_location_menu_selected")?.withRenderingMode(.alwaysOriginal), for: .selected)
        
        // Init second item
        let secondItem = SVCTabItem(type: .system)
        secondItem.imageViewAnimators = [SVCTransitionAnimator(transitionOptions: .transitionFlipFromRight)]
        secondItem.setImage(UIImage(named: "ic_users_menu_normal")?.withRenderingMode(.alwaysOriginal), for: .normal)
        secondItem.setImage(UIImage(named: "ic_users_menu_selected")?.withRenderingMode(.alwaysOriginal), for: .selected)
        
        // Init third item
        let thirdItem = SVCTabItem(type: .system)
        thirdItem.imageViewAnimators = [SVCTransitionAnimator(transitionOptions: .transitionFlipFromBottom)]
        thirdItem.setImage(UIImage(named: "ic_media_menu_normal")?.withRenderingMode(.alwaysOriginal), for: .normal)
        thirdItem.setImage(UIImage(named: "ic_media_menu_selected")?.withRenderingMode(.alwaysOriginal), for: .selected)
        
        defaultTabBar.items = [firstItem, secondItem, thirdItem]
        
        // inject tab bar
        tabBar = defaultTabBar
    }
}

Item animations:

You can use different Animators for SVCTabItem. SwipeVC has SVCBounceAnimator(), SVCRotationAnimator(), SVCImagesAnimator(), SVCTransitionAnimator() ...

let tabBarItem = SVCTabItem(type: .system)
tabBarItem.imageViewAnimators = [SVCBounceAnimator()]
tabBarItem.titleLabelAnimators = [SVCTransitionAnimator(transitionOptions: .transitionFlipFromBottom)]

Or create your own Animator simply realized SVCAnimator protocol.

open class SomeCustomAnimator: SVCAnimator {
    open func select(onView view: UIView) {
        // Some select animation
    }

    open func deselect(onView view: UIView) {
        // Some deselect animation
    }
}

// And simple set animator to your item(image or title)
tabBarItem.imageViewAnimators = [SomeCustomAnimator()]
tabBarItem.titleViewAnimators = [SomeCustomAnimator()]

For use movable line view you should set "defaultTabBar.movableView.isHidden = false". You can customize your movableView (width, height, bouncing, attach).

func tabBarInjection() {
    let defaultTabBar = SVCTabBar()
    showMovableView(onDefaultTabBar: defaultTabBar)

    // Add some items ...

    // inject tab bar
    tabBar = defaultTabBar
}

func showMovableView(onDefaultTabBar defaultTabBar: SVCTabBar) {
    defaultTabBar.movableView.isHidden = false
    defaultTabBar.movableView.backgroundColor = ExampleSwipeViewController.defaultStyleColor
    defaultTabBar.movableView.bouncing = 0.5
    defaultTabBar.movableView.width = 64
    defaultTabBar.movableView.height = 1
    defaultTabBar.movableView.attach = .bottom
}

Example target

You can check more functionality of SwipeVC in Example target.

License

SwipeVC is released under an MIT license. See License.txt for more information.

swipevc's People

Contributors

panevnyk avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar

swipevc's Issues

Add title

I want to add title with tab item but not providing any property for it

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.