ZoomTransitioning

ZoomTransitioning provides a custom transition with image zooming animation and swiping the screen edge.

Github stars Tracking Chart

ZoomTransitioning

Join the chat at https://gitter.im/WorldDownTown/ZoomTransitioning

License
Swift
Carthage compatible
CocoaPods compatible
CocoaPods
Awesome

Overview

ZoomTransitioning provides a custom transition with image zooming animation.
When you use this library with UINavigationController, you can pop view controller with edge swiping.

Demo

Run the demo project in the Demo directory without carthage update or pod install.

Usage

Refer to the example project for details.

import ZoomTransitioning

Adopt ZoomTransitionSourceDelegate to source view controller

extension ImageListViewController: ZoomTransitionSourceDelegate {

    func transitionSourceImageView() -> UIImageView {
        return selectedImageView
    }

    func transitionSourceImageViewFrame(forward forward: Bool) -> CGRect {
        return selectedImageView.convertRect(selectedImageView.bounds, toView: view)
    }

    func transitionSourceWillBegin() {
        selectedImageView.hidden = true
    }

    func transitionSourceDidEnd() {
        selectedImageView.hidden = false
    }

    func transitionSourceDidCancel() {
        selectedImageView.hidden = false
    }
}

Adopt ZoomTransitionDestinationDelegate to destination view controller

extension ImageDetailViewController: ZoomTransitionDestinationDelegate {

    func transitionDestinationImageViewFrame(forward forward: Bool) -> CGRect {
        if forward {
            let x: CGFloat = 0.0
            let y = topLayoutGuide.length
            let width = view.frame.width
            let height = width * 2.0 / 3.0
            return CGRect(x: x, y: y, width: width, height: height)
        } else {
            return largeImageView.convertRect(largeImageView.bounds, toView: view)
        }
    }

    func transitionDestinationWillBegin() {
        largeImageView.hidden = true
    }

    func transitionDestinationDidEnd(transitioningImageView imageView: UIImageView) {
        largeImageView.hidden = false
        largeImageView.image = imageView.image
    }

    func transitionDestinationDidCancel() {
        largeImageView.hidden = false
    }
}

set delegate property of UINavigationController

import ZoomTransitioning

class NavigationController: UINavigationController {

    private let zoomNavigationControllerDelegate = ZoomNavigationControllerDelegate()

    required init?(coder aDecoder: NSCoder) {
        super.init(coder: aDecoder)

        delegate = zoomNavigationControllerDelegate
    }
}

Requirements

  • Swift 4.0
  • iOS 9.0 or later

If you use Swift 2.2, use 1.3.0

Installation

Carthage

ZoomTransitioning is available through Carthage. To install it, simply add the following line to your Cartfile:

github "WorldDownTown/ZoomTransitioning"

CocoaPods

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

pod 'ZoomTransitioning'

Manually

  1. Download and drop /ZoomTransitioningfolder in your project.
  2. Congratulations!

Author

WorldDownTown, WorldDownTown@gmail.com

License

ZoomTransitioning is available under the MIT license. See the LICENSE file for more info.

Main metrics

Overview
Name With OwnerWorldDownTown/ZoomTransitioning
Primary LanguageSwift
Program languageRuby (Language Count: 3)
Platform
License:MIT License
所有者活动
Created At2016-07-07 23:00:29
Pushed At2019-07-01 23:52:56
Last Commit At2019-07-02 08:52:55
Release Count11
Last Release Name1.6.0 (Posted on )
First Release Name1.0.0 (Posted on )
用户参与
Stargazers Count672
Watchers Count18
Fork Count54
Commits Count64
Has Issues Enabled
Issues Count12
Issue Open Count3
Pull Requests Count8
Pull Requests Open Count0
Pull Requests Close Count1
项目设置
Has Wiki Enabled
Is Archived
Is Fork
Is Locked
Is Mirror
Is Private