Giter Club home page Giter Club logo

psgestures's Introduction

PSGestures is a library for iOS. It's designed to allow the developer to handle gestures without any code. Simple subclass your view from PSTransformableView to get pan, zoom and rotation working!

However, if you would like to dive deeper and implement custom gesture behavior, this library makes it possible, too; just set a delegate to your transformable view.

How To Get Started

  • Import PSGestures.h file in your project
  • Subclass your view from PSTransformableView
  • Start the app and see the gestures working!

Requirements

  • iOS 7 and later

Usage

Create your own CustomView class and subclass it from PSTransformableView:

#import "PSGestures.h"

@interface CustomView : PSTransformableView
// Your class' public properties and methods
@end

Then, create an instance of your CustomView class and bring it to some superview.

Now you can start the app and pan, zoom, and rotate the view. All gestures are handled automatically by PSTransformableView class.

Let's disable default implementation for some of gestures. It's possible this way:

[customView setGestureWithType:PSTransformableViewGestureTypePan enabled:NO];
[customView setGestureWithType:PSTransformableViewGestureTypePinch enabled:NO];
[customView setGestureWithType:PSTransformableViewGestureTypeRotation enabled:YES];

Also, you can check whether or not default gesture behavior is enabled:

BOOL isEnabled = [customView isGestureWithTypeEnabled:PSTransformableViewGestureTypeRotation];

When you would like to receive debug information regarding with gestures, or want to implement additional custom behavior, it's possible with the PSTransformableViewDelegate protocol:

#import "PSGestures.h"

@interface CustomView : PSTransformableView<PSTransformableViewDelegate>
@end

Implement the only method of this protocol in your view's .m file:

- (void)transformableView:(PSTransformableView *)view retrievedGestureOfType:(PSTransformableViewGestureType)type inState:(PSTransformableViewGestureState)state touchedPoints:(NSArray *)points
{
    NSString *typeString = NSStringFromPSTransformableViewGestureType(type);
    NSString *stateString = NSStringFromPSTransformableViewGestureState(state);
    
    NSLog(@"Gesture of type %@ in state %@ with touch count %lu",
          typeString,
          stateString,
          (unsigned long)points.count);
}

This method will receive gesture's type, state, and array of NSValue objects containing CGPoint for every one of the touched points. So, this method only tells you as much as all existing UIGestureRecognizer subclasses together. PSGestures provides all needed information without the need to write gesture selectors.

License

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

psgestures's People

Contributors

wittedhaddock avatar

Watchers

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