项目作者: marcosgriselli

项目描述 :
UITabBarController with swipe interaction between its tabs.
高级语言: Swift
项目地址: git://github.com/marcosgriselli/SwipeableTabBarController.git
创建时间: 2017-02-01T20:04:06Z
项目社区:https://github.com/marcosgriselli/SwipeableTabBarController

开源协议:MIT License

下载


SwipeableTabBarController

Version
iOS 8.0+
Swift 4.2
Cartage
License
codebeat badge

🌟 Features

  • Zero setup
  • Different animations
  • Enable/Disable interactions easily
  • Fluid gestures

📲 Installation

Using CocoaPods

Edit your Podfile and specify the dependency:

  1. pod 'SwipeableTabBarController'

Using Carthage

Edit your Cartfile and specify the dependency:

  1. github "marcosgriselli/SwipeableTabBarController"

Manual

Drop the classes inside of SwipeableTabBarController/Classes into your project.

👩‍💻 How to use

Setup

If you don’t need subclassing UITabBarController just set the UITabBarController on the Storyboard to be of type SwipeableTabBarController.

Otherwise, make a subclass of SwipeableTabBarController.

  1. import SwipeableTabBarController
  2. class TabBarController: SwipeableTabBarController {
  3. // Do all your subclassing as a regular UITabBarController.
  4. }

Animations

SwipeableTabBarController supports 3 different types of animations out of the box. Setting the desired animation is easy. On your SwipeableTabBarController subclass just do:

  1. swipeAnimatedTransitioning?.animationType = SwipeAnimationType.sideBySide

If you are supporting just one type of animation call it on viewDidLoad() otherwise call it as you need to change the desired animation.

Side by Side (default)

The default animation is SwipeAnimationType.sideBySide where the newly selected tab will move in at the same speed the previous one moves out.

Overlap

SwipeAnimationType.overlap the newly selected tab will move in to take the central place on top of the previous one which will hold it’s position.

Push

SwipeAnimationType.push follows iOS default push animation where the top view moves away while the bottom one slightly moves behind. In this case, the top view will be the previously selected tab view.

Enable Cycling

SwipeableTabBarController supports cycling between the first and last tab like a carousel. Simply set isCyclingEnabled to true.

Default value is false

  1. isCyclingEnabled = true

Minimum/Maximum number of touches

You can set both the minimum and the maximum number of touches needed to handle the swipe gesture. Simply set minimumNumberOfTouches or maximumNumberOfTouches property.

Default value is 1

  1. minimumNumberOfTouches = 2

Default value is Int.max

  1. maximumNumberOfTouches = 2

Disable Interaction

Support for disabling/enabling the interactor, this can be used on a controller that uses horizontal scrollView or a Map (in the example).

Default value is true

  1. isSwipeEnabled = false

❤️ Contributing

This is an open source project, so feel free to contribute. How?

  • Open an issue.
  • Send feedback via twitter.
  • Propose your own fixes, suggestions and open a pull request with the changes.

Contributors

👨‍💻 Author

Marcos Griselli | @marcosgriselli

Twitter Follow

GitHub Follow

🛡 License

  1. MIT License
  2. Copyright (c) 2018 Marcos Griselli
  3. Permission is hereby granted, free of charge, to any person obtaining a copy
  4. of this software and associated documentation files (the "Software"), to deal
  5. in the Software without restriction, including without limitation the rights
  6. to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
  7. copies of the Software, and to permit persons to whom the Software is
  8. furnished to do so, subject to the following conditions:
  9. The above copyright notice and this permission notice shall be included in all
  10. copies or substantial portions of the Software.
  11. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
  12. IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
  13. FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
  14. AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
  15. LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
  16. OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
  17. SOFTWARE.