GithubHelp home page GithubHelp logo

adamnemecek / xmcirclegesturerecognizer Goto Github PK

View Code? Open in Web Editor NEW

This project forked from michmich/xmcirclegesturerecognizer

0.0 2.0 0.0 1.02 MB

An one finger circle gesture recognizer in swift.

Home Page: http://michaelteeuw.nl/post/90182386142/swift-around-and-around

License: Apache License 2.0

Swift 100.00%

xmcirclegesturerecognizer's Introduction

XMCircleGestureRecognizer

XMCircleGestureRecognizer was written by Michael Teeuw

What is it?

An one finger circle gesture recognizer written in swift.

How to use

Add a XMCircleGestureRecognizer recognizer to your view

let cgr = XMCircleGestureRecognizer(midPoint: self.view.center, innerRadius:10, outerRadius:200, target: self, action: "rotateGesture:"))
view.addGestureRecognizer(cgr)

Or, of you don't need a minimum and maximum distance to your center point:

let cgr = XMCircleGestureRecognizer(midPoint: self.view.center, target: self, action: "rotateGesture:"))
view.addGestureRecognizer(cgr)

Add a gesture responder function to your target to respond to the gesture:

func rotateGesture(recognizer:XMCircleGestureRecognizer)
{
    if let rotation = recognizer.rotation {
        // rotation is the relative rotation for the current gesture in radians
    }
    
    if let angle = recognizer.angle {
        // angle is the absolute angle for the current gesture in radians
    }
    
    if let distance = recognizer.distance {
        // distance is the absolute distance from the midPoint
    }
}

If you like to transform the values from radians to degrees, simply add .degrees to the variable:

if let rotation = recognizer.rotation {
    // rotation.degrees is the relative rotation for the current gesture in degrees
}

So what does it look like?

Disclaimer

This is my fist open source Swift class. So be gentle. ;)

Contributing

Forks, patches and other feedback are welcome.

xmcirclegesturerecognizer's People

Contributors

davidebettio avatar michmich avatar

Watchers

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