Sensitive
is a library that simplifies work with gestures in iOS. Forget about target/action pattern of primitive UIGestureRecognizer
. With Sensitive
you can call onTap
, onPinch
, onSwipe
on any UIView
instance and implement handler for the gesture. That's all that you should know to start. For details, see Usage section.
I dedicate a considerable amount of my free time to developing and maintaining my open source software. To help ensure this package is kept updated, new features are added and bugfixes are implemented quickly, please donate a couple of dollars (or a little more if you can stretch) as this will help me to afford to dedicate time to its maintenance. Please consider donating if you're using this software in an app that makes you money, if you're being paid to make the app, if you're asking for new features or priority bug fixes. I accept donations only in Bitcoin and Ethereum. Thank you for your support!
Bitcoin: 3GYbxsDPni2TDiijiiKWh2RvWyx8YeMa14
Ethereum: 0x576E29793F1BdfF6fA061D096feb8197E7Aae78B
- Copy content of
Source
folder to your project.
or
- Use
Sensitive
cocoapod.
- iOS 9.0 and later
- Xcode 9.0 and later
- Swift 4.1 or later
All gestures are available via special variables that you can call on any UIView
instance. Examples:
view.onTap
.configure(with: { (gestureRecognizer) in
// Configure `UITapGestureRecognizer` instance
gestureRecognizer.numberOfTapsRequired = 2
})
.handle { (gestureRecognizer) in
// Handle tap on view
gestureRecognizer.view!.backgroundColor = .green
}
view.onSwipe
.configure(with: { (gestureRecognizer) in
// Configure `UISwipeGestureRecognizer` instance
gestureRecognizer.direction = .left
})
.handle { (gestureRecognizer) in
// Handle tap on view
gestureRecognizer.view!.backgroundColor = .green
}
Full list of available gestures:
onTap
onLongPress
onPan
onPinch
onRotation
onSwipe
onScreenEdgePan
If you need few gestures to work together on the same view, you can also use recognizeSimultaneously
method:
view.onTap
.handle { (gestureRecognizer) in
// Your implementation here...
}
.recognizeSimultaneously(true)
view.onPinch
.handle { (gestureRecognizer) in
// Your implementation here...
}
.recognizeSimultaneously(true)
Sensitive
is available under the MIT license. See the LICENSE file for more info.