Instead of scaling, which I think pinch gesture is usually used for, I am looking to just detect whether the pinch was a pinch in vs pinch out so I can collapse or expand some table sections. How would I go about doing that?
相关问题
- CALayer - backgroundColor flipped?
- Core Data lightweight migration crashes after App
- How can I implement password recovery in an iPhone
- State preservation and restoration strategies with
- “Zero out” sensitive String data in Swift
相关文章
- 现在使用swift开发ios应用好还是swift?
- UITableView dragging distance with UIRefreshContro
- TCC __TCCAccessRequest_block_invoke
- Where does a host app handle NSExtensionContext#co
- xcode 4 garbage collection removed?
- Xcode: Is there a way to change line spacing (UI L
- Unable to process app at this time due to a genera
- Swift - hide pickerView after value selected
Well, that seems an easy one. The
UIPinchGestureRecognizer
class has only two properties,scale
andvelocity
. It seems logical that a negativescale
would mean an inward pinch, a positivescale
an outward pinch.NB: "negative" might be misleading. "Smaller" is
0.0 < scale < 1.0
, "bigger" isscale > 1.0
.The "scale" property is less than 1 for pinch-in gesture and greater than 1 for pinch-out. This happens for all pinches with 2 fingers.
What I also observed was that if I pinched in with 5 fingers (which is the shortcut to minimize-to-home), the scale value comes exactly 1.0 - everytime. But this is not supported by any Apple documentation that I'm aware of.
You can experiment what the values are coming by simply putting an NSLog in your pinch handling selector
You were right to look at the scale property however it switches around 1, not zero.