Giter VIP home page Giter VIP logo

swipetransition's Introduction

logotype-a

Build Status Carthage compatible pods Platform Swift Version Objective-C compatible

SwipeTransition allows trendy transitions using swipe gesture such as "swipe back".

Demo

Try the demo on the web (appetize.io):ใ€€https://appetize.io/app/pebm8kveqhfj3wn204adn0xu8r

Features

  • Swipe back anywhere.
  • Swipe to dismiss anywhere.
  • Apply to all view controllers automatically!
  • No conflict of gestures on UIScrollView, UITableView, UICollectionView and so on.

Requirements

  • Xcode 10.2 (10.0+)
  • Swift 5 (4.2+)
  • iOS 8.0+

Installation

Carthage

github "tattn/SwipeTransition"

CocoaPods

pod "SwipeTransition"
pod "SwipeTransitionAutoSwipeBack"      # if needed
pod "SwipeTransitionAutoSwipeToDismiss" # if needed

Usage

The easiest way to use

Just setting these frameworks in the Linked Frameworks and Libraries, it works. (if you use Carthage)

Linked Frameworks and Libraries

Notes: these frameworks use Method Swizzling.

If you want to set up manually without Method Swizzling, please use SwipeTransition.framework only.

Manually set up

Notes: if you use `AutoSwipeBack.framework`, these are unnecessary.

Just use SwipeBackNavigationController instead of UINavigationController. Of course, you can set it with Interface Builder.

let viewController = UIViewController()
let navigationController = SwipeBackNavigationController(rootViewControlelr: viewController)

Another way is to set swipeBack.

class CustomNavigationController: UINavigationController {
    override func viewDidLoad() {
        super.viewDidLoad()
        swipeBack = SwipeBackController(navigationController: self)
    }
}
Notes: if you use `AutoSwipeToDismiss.framework`, these are unnecessary.

Just use SwipeToDismissNavigationController instead of UINavigationController. Of course, you can set it with Interface Builder.

let viewController = UIViewController()
let navigationController = SwipeToDismissNavigationController(rootViewControlelr: viewController)

Another way is to set swipeToDismiss.

class CustomNavigationController: UINavigationController {
    override func viewDidLoad() {
        super.viewDidLoad()
        modalPresentationStyle = .fullScreen
        swipeToDismiss = SwipeToDismissController(viewController: self)
    }
}

Enable/Disable gestures

Use isEnabled property.

self.navigationController?.swipeBack?.isEnabled = false
self.swipeToDismiss?.isEnabled = false

Configuration

You can also change the behavior such as animation.

SwipeBackConfiguration.shared.parallaxFactor = 0.6

SwipeToDismissConfiguration.shared.dismissHeightRatio = 0.5

Inheriting the configure class, you can set it with computed property.

class CustomSwipeBackConfiguration: SwipeBackConfiguration {
    override var transitionDuration: TimeInterval {
        get { return 1.5 }
        set { super.transitionDuration = newValue }
    }
}

SwipeBackConfiguration.shared = CustomSwipeBackConfiguration()

Other usage

See this wiki

Contributing

  1. Fork it!
  2. Create your feature branch: git checkout -b my-new-feature
  3. Commit your changes: git commit -am 'Add some feature'
  4. Push to the branch: git push origin my-new-feature
  5. Submit a pull request :D

Support this project

Donating to help me continue working on this project.

Donate

ToDo

  • All .modalPresentationStyle support
  • Animation support (fade / custom)
  • Some transition styles support (e.g. right to left swipe transition)

License

SwipeTransition is released under the MIT license. See LICENSE for details.

swipetransition's People

Contributors

abllogra avatar dependabot[bot] avatar rnishimu22001 avatar shmakovigor avatar tattn avatar tobaloidee avatar

Watchers

 avatar  avatar

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.