Skip to content

TheMindStudios/KnobGestureRecognizer

Repository files navigation

KnobGestureRecognizer

Version Swift 3.0.x

TheMindStudios

Features

  • knob gesture
  • get rotation radians of gesture
  • set center of knob rotation
  • get distance from center to touch (radius)
  • get rotation direction (clockwise/ counter clockwise)

Example Example

Usage

  1. Import KnobGestureRecognizer module to your UIView class/subclass
   import KnobGestureRecognizer
  1. Add gesture recognizer KnobGestureRecognizer to view
   override func awakeFromNib() {
       super.awakeFromNib()

       let gesture = KnobGestureRecognizer(target: self, action: #selector(rotationAction(_:)), to: controlView)

       gesture.delegate = self
       controlView.addGestureRecognizer(gesture)
   } 
  1. Processing callback
    @objc fileprivate func rotationAction(_ sender: KnobGestureRecognizer) {
         ...
      }

Installation with CocoaPods

To install via CocoaPods add this lines to your Podfile. You need CocoaPods v. 1.1 or higher

  $ gem install cocoapods

Podfile

To integrate KnobGestureRecognizer into your Xcode project using CocoaPods, specify it in your Podfile:

source 'https://github.com/CocoaPods/Specs.git'
platform :ios, '9.0'
use_frameworks!

target 'TargetName' do
  pod 'KnobGestureRecognizer', '~> 1.0'
end

Then, run the following command:

  $ pod install

Properties

Rotation in radians

fileprivate(set) open var rotation: CGFloat = 0.0

Rotation direction

fileprivate(set) open var clockwiseDirection: Bool = true

Distance from anchor point

fileprivate(set) open var radius: Float? = 0.0

Knob center

open var anchor: CGPoint?

License

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

About

Custom knob gesture recognition implementation for iOS

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Contributors 3

  •  
  •  
  •