Latest 1.2.0
Homepage https://github.com/vhyme/AnyPullBack
License MIT
Platforms ios 8.0, requires ARC
Frameworks UIKit
Authors




A simple navigation controller with pixel-perfect push animation and pop gesture in any direction you like!

Note: Experimental support for UIScrollViews (and all other views based on UIScrollView, e.g. UITableView and UIWebView) is provided, which means all the UIScrollViews you are touching should be scrolled left-/top-/bottom-most to trigger swiping right/down/up gestures. All the touched UIScrollViews (except those in the rootViewController) will be set bounces = false to achieve this.

Written in Swift 3.

Preview

Run pod try AnyPullBack, change the bundle identifier and development team, build the project and run on your phone!

View video

Installation

Add pod 'AnyPullBack' to your Podfile.

Usage

Use AnyPullBackNavigationController any way you like.

Inheritage notice

The class AnyPullBackNavigationController is open, which means you can inherit the class and make your own subclasses. However, please make sure to call super.viewDidLoad() if your subclass overrides the viewDidLoad method, otherwise it will have all the features disabled, working like a pure UINavigationController.

APIs

  • All APIs from UINavigationController are available.

  • defaultPushAnimator

Set the default animator used by pushViewController(_:animated:). Initialize a ScaleInAnimator with a source rect or source view, or a SwipeInAnimator with any direction you like.

  • defaultPopAnimator

Set the default animator used by popViewController(animated:). Initialize a SwipeOutAnimator with a direction you like.

  • pullableWidthFromLeft: CGFloat

Default is 0. Set the width of the region where swiping right is valid for popping the current ViewController. To enable swiping-right gesture all over the screen, set it to 0.

  • canPullFromLeft | canPullFromTop | canPullFromBottom

The main control for the swiping gestures. Default is all true.

  • pushViewController(_:fromView:)

Push a ViewController with a temporary ScaleInAnimator to provide scale-in animation from a specific view.

Note: Compared with pushViewController(_:fromRect:), this method provides smoother transition where the source view fades out rather than being suddenly covered by a white rectangle.

  • pushViewController(_:fromRect:)

Push a ViewController with a temporary ScaleInAnimator to provide scale-in animation from a specific rect.

  • pushViewController(_:inDirection:)

Push a ViewController in a specific direction. Available directions are .leftFromRight, .rightFromLeft, .upFromBottom, .downFromTop.

  • popViewController(inDirection:)

Pop a ViewController in a specific direction. Available directions are .rightFromLeft, .leftFromRight, .downFromTop, .upFromBottom.

  • protocol AnyPullBackCustomizable

Extend your UIViewController with AnyPullBackCustomizable and specify the method UIViewController::apb_shouldPull(inDirection:) -> Bool to customize whether you allow the current view controller to be pulled from a specific direction. The method is called when the user tries to pull from a direction.

Note: This method can be called multiple times during a single swipe gesture, until it returns true to allow the swiping. Please be careful with this detail.

Example:

class ExampleViewController: UIViewController, AnyPullBackCustomizable {

    func apb_shouldPull(inDirection direction: SwipeOutDirection) -> Bool {

        // To only enable pulling from left for this view controller
        return direction == .rightFromLeft

        // To disable pull-to-back completely for this view controller
        return false
    }
}

Latest podspec

{
    "name": "AnyPullBack",
    "version": "1.2.0",
    "summary": "Swipe right/down/up to go back in the simple Navigation Controller",
    "homepage": "https://github.com/vhyme/AnyPullBack",
    "license": "MIT",
    "authors": {
        "Vhyme Riku": "[email protected]"
    },
    "source": {
        "git": "https://github.com/vhyme/AnyPullBack.git",
        "tag": "1.2.0"
    },
    "documentation_url": "https://github.com/vhyme/AnyPullBack",
    "platforms": {
        "ios": "8.0"
    },
    "source_files": "AnyPullBack",
    "frameworks": "UIKit",
    "requires_arc": true,
    "pushed_with_swift_version": "3.0"
}

Pin It on Pinterest

Share This