GithubHelp home page GithubHelp logo

veverka / zoomtransitioning Goto Github PK

View Code? Open in Web Editor NEW

This project forked from worlddowntown/zoomtransitioning

0.0 2.0 0.0 22.88 MB

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

License: MIT License

Swift 92.28% Ruby 5.19% Objective-C 2.53%

zoomtransitioning's Introduction

ZoomTransitioning

License Language Carthage compatible CocoaPods compatible 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

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 3.0
  • iOS 8.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, [email protected]

License

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

zoomtransitioning's People

Contributors

worlddowntown avatar lfarah avatar

Watchers

James Cloos avatar Elena 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.