Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/michmich/xmcirclegesturerecognizer
An one finger circle gesture recognizer in swift.
https://github.com/michmich/xmcirclegesturerecognizer
Last synced: 2 months ago
JSON representation
An one finger circle gesture recognizer in swift.
- Host: GitHub
- URL: https://github.com/michmich/xmcirclegesturerecognizer
- Owner: MichMich
- License: apache-2.0
- Created: 2014-06-21T19:58:22.000Z (over 10 years ago)
- Default Branch: master
- Last Pushed: 2016-10-03T12:14:13.000Z (over 8 years ago)
- Last Synced: 2024-10-14T10:21:57.841Z (3 months ago)
- Language: Swift
- Homepage: http://michaelteeuw.nl/post/90182386142/swift-around-and-around
- Size: 1020 KB
- Stars: 79
- Watchers: 5
- Forks: 13
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
XMCircleGestureRecognizer
=========================**XMCircleGestureRecognizer** was written by **[Michael Teeuw](https://twitter.com/michmich)**
## What is it?
An one finger circle gesture recognizer written in swift.
## How to use
Add a XMCircleGestureRecognizer recognizer to your viewlet 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?
![](https://raw.github.com/MichMich/XMCircleGestureRecognizer/master/Screenshots/example.gif)
## Disclaimer
This is my fist open source Swift class. So be gentle. ;)
## Contributing
Forks, patches and other feedback are welcome.