Git Product home page Git Product logo

interactivezoomdriver's Introduction

InteractiveZoomDriver

This repo is view to zoomable by pinch gesture.

Overview

Installation

Carthage

For Installing with Carthage, add it to your Cartfile.

github "shima11/InteractiveZoomDriver"

CocoaPods

For installing with CocoaPods, add it to your Podfile.

pod 'InteractiveZoomDriver'

Usage

import InteractiveZoomDriver

let zoomView = UIImageView() // UIView or SubClass of UIView
zoomView.isUserInteractionEnabled = true

Case1: driver

Add zoom function to target UIView.

gestureTargetView: added tap and pan gesture.
sourceView: source view.
targetViewFactory: Transformed View during zooming.
shouldZoomTransform: Delegate to the outside whether zooming is possible.

let driver = InteractiveZoomDriver(
  gestureTargetView: imageView2,
  sourceView: imageView2,
  targetViewFactory: { (fromImageView: UIImageView) -> UIView in
    let view = UIImageView()
    view.image = fromImageView.image
    view.clipsToBounds = fromImageView.clipsToBounds
    view.contentMode = fromImageView.contentMode
    return view
  },
  shouldZoomTransform: {(sourceView: UIImageView) -> Bool in
    if sourceView.image == nil {
      return false
    }
    return true
  }
)

This is also no problem. InteractiveZoomView.clone and InteractiveZoomView.shouldZoomTransform is default implementation of protocol extension. InteractiveZoomView corresponds to UIImageView only. To support other than UIImageView, add an implementation in extension.

let driver = InteractiveZoomDriver(
  gestureTargetView: zoomView, 
  sourceView: zoomView, 
  targetViewFactory: InteractiveZoomView.clone, 
  shouldZoomTransform: InteractiveZoomView.shouldZoomTransform
)

Case2: overlay view

InteractiveZoomView is able to only UIImageView now.
If you want to use custom UIView, you need to create extension of InteractiveZoomView with reference to InteractiveZoomView.

let overlayZoomView = InteractiveZoomView(
    sourceView: zoomView
)
view.addSubView(overlayZoomView)

interactivezoomdriver's People

Contributors

muukii avatar shima11 avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar

interactivezoomdriver's Issues

Getting problem when pinch for imageview with sublayer

Hello there,

I am using this repo in one of my application where I need to enable zoom with pinch functionality for both images and videos like instagram. In which, for only images it is working good. And for videos I have added avplayer layer to the imageview. when I add the driver to the imageview with video sublayer, the image is getting zoom. but the video layer is not.

So, How to deal with this? Please help me out.

Thank You!

[Privacy Manifest] Implementation

Hello,

As we approach the upcoming spring and the anticipated implementation of the Privacy Manifest by Apple, it's crucial to ensure that your SDK fully complies with Apple's requirements.

Does your SDK need to include it?
If so, do you have a release date planned?

Thank you in advance for your attention to this matter.

Best regards

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.