Git Product home page Git Product logo

tmimagezoom's Introduction

TMImageZoom

Easily add zoom functionality similar to Instagram

Getting Started

Adding TMImageZoom is quick and easy:

  1. Add the TMImageZoom.h & TMImageZoom.m files to your project.
  2. Import TMImageZoom.h

Installing

Start by adding a UIPinchGestureRecognizer to the view you would like to receive touches and create a pinch: method

UIPinchGestureRecognizer *pinchZoom = [[UIPinchGestureRecognizer alloc] initWithTarget:self action:@selector(pinch:)];
pinchZoom.delegate = self;
[self addGestureRecognizer:pinchZoom];

- (void)pinch:(UIPinchGestureRecognizer *)gesture {
    
}

Then inside the pinch: method, use the shared instance of TMImageZoom and call the gestureStateChanged: method. We will pass the gesture as well as the UIImageView we would like to zoom.

- (void)pinch:(UIPinchGestureRecognizer *)gesture {
    [[TMImageZoom shared] gestureStateChanged:gesture withZoomImageView:imageView];
}

And that’s it! You can now pinch zoom the image just like Instagram!

FAQ

“How do I know if the user is currently zooming the image?”

[[TMImageZoom shared] isHandlingGesture]

“How can I manually end the zoom?”

[[TMImageZoom shared] resetImageZoom]

“Do I need to call resetImageZoom: everytime to reset the zoom?”

A: No, this is called automatically when the user ends the gesture.

“Is there anyway I can know when the user starts and ends the zoom?”

A: Yes, we post two notifications when the user begins and ends zooming:
TMImageZoom_Started_Zoom_Notification
TMImageZoom_Ended_Zoom_Notification

“Does this support CollectionViews and TableViews?”

A: Yes, although you will need to manually override touches so the user can’t tap other cells/buttons while zooming. This can be achieved by checking the isHandlingGesture boolean.

“Can you zoom multiple ImageViews at once?”

A: This is possible but only if you don’t use the shared instance and just initialise TMImageZoom yourself. Currently with the shared instance we block any gestures that get received if it isn’t the current view being zoomed. (This resets everytime the zoom is reset)

Known Issues

None at this stage, I’ll actively monitor issues if they arise.

Authors

License

Copyright (c) 2009-2016: Thomas Maw

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

tmimagezoom's People

Contributors

twomedia avatar rayrw avatar

Watchers

Nicholas 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.