Code Monkey home page Code Monkey logo

hkrewind's Introduction

HKRewind

Screenshot

HKRewind features a UIGestureRecognizer subclass and a HUD view that help you implement a rewind gesture à la Paper by Fifty-Three.

HKRewind uses Auto-layout, which makes it iOS6+ compatible only. It should be noted that HKRewind uses HKCircularProgressView (version 1.1.0)

How to use it

  1. Use CocoaPods by adding pod 'HKRewind' in your Podfile.
  2. Manually:
  • Clone HKCircularProgressView (version 1.1.0) and import its files.
  • Clone this repository
  • Copy HKRewindGestureRecognizer, HKRewindView, HKArcPoints, HKGeometryHelpers, HKRewindHUD files (.h, .m and .mm) into your project.

Import *HKRewindGestureRecognizer.h", add an instance of this recognizer to your view and use it as you would with any subclass of UIGestureRecognizer. If you want to use the HUD view import HKRewindHUD.h, create a HUD for your view with the HUDForView:(UIView *)view method and show/hide it with showHUDAnimated:(BOOL)animated and hideHUDAnimated:(BOOL)animated.

For a simple example, pleaser refer to the HKRewindViewController class in this repository.

How to configure it

HKRewindGestureRecognizer

HKRewindGestureRecognizer emits 3 UIGestureRecognizerStates: UIGestureRecognizerStateBegan (this is when you should show the HUD), UIGestureRecognizerStateChanged (this is when you should use the rotationDelta property in order to update the HUD) and UIGestureRecognizerStateEnded (this is when you should hide the HUD).

You can customize the behavior of the gesture recognizer by editing those properties:

  • numberOfTouchesRequired: the number of fingers that must be touching the view for this gesture to be recognized. The default value is 2.
  • timeout: the number of seconds the user is allowed to be inactive before the recognizer is cancelled. Default is 1.
  • maximumRadius: the approximate radius of the circle that the user is likely to draw. If a visual cue is shown (like a circle) when the user performs the gesture, it should be set to the visual cue's radius. Default is 200.
  • maximumRotationDelta: the maximum absolute value that rotationDelta will be assigned, in radians. Default value is Pi/50.

In order to retrieve the information provided by the gesture recognizer, use those properties:

  • rotationDelta: angle, in radians, described by the user since the previous move. This is a signed value, do not use the clockwise property to negate this value.
  • clockwise: boolean value determining whether the user is performing a clockwise rotation or not.
  • velocity: the velocity of the rotation gesture in radians per second.

HKRewindHUD

You should not init HKRewindHUD like a normal view, but instead you should use the + (instancetype)HUDForView:(UIView *)view method. Show and hide the HUD with showHUDAnimated:(BOOL)animated and hideHUDAnimated:(BOOL)animated.

You can customize the behavior of the HUD by accessing and editing those properties:

  • rewindView: the underlying HKRewindView that is displayed. Use the - (void)addProgression:(CGFloat)rotationDelta method on this property to update the progression. You can also customize the appearance of the view, please refer to HKRewindView's documentation for more information.
  • animationDuration: the fade-in/fade-out animation duration. Default is 0.25 seconds.
  • animationDelay: the fade-in/fade-out animation delay. Default is 0 seconds.

hkrewind's People

Contributors

harmek avatar

Watchers

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