- 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)
- Import
KnobGestureRecognizer
module to yourUIView
class/subclass
import KnobGestureRecognizer
- 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)
}
- Processing callback
@objc fileprivate func rotationAction(_ sender: KnobGestureRecognizer) {
...
}
To install via CocoaPods add this lines to your Podfile. You need CocoaPods v. 1.1 or higher
$ gem install cocoapods
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
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?
KnobGestureRecognizer is available under the MIT license. See the LICENSE file for more info.