This last one is interesting because it allows you to reset the translation so far
By resetting the translation to zero all the time, you end up getting “incremental” translation
The abstract superclass also provides state information
var state: UIGestureRecognizerState { get } This sits around in .Possible until recognition starts For a discrete gesture (e.g. a Swipe), it changes to .Recognized (Tap is not a normal discrete) For a continues gesture (e.g. a Pan), it moves from .Began thru repeated .Changed to .Ended It can go to .Failed or .Cancelled too, so watch out for those!
So, given this information, what would the pan handler look like?
func pan(gesture: UIPanGestureRecognizer) {
switch gesture.state {
case .Changed: fallthrough
case .Ended:
let translation = gesture.translationInView(pannableView)
// update anything that depends on the pan gesture using translation.x and .y
 gesture.setTranslation(CGPointZero, inView: pannableView)
default: break
}
}
Remember that the action was “pan:” (if no colon, we would not get the gesture argument)
We are only going to do anything when the finger moves or lifts up off the device’s surface
fallthrough means “execute the code for the next case down”
Here we get the location of the pan in the pannableView’s coordinate system
Now we do whatever we want with that information
By resetting the translation, the next one we get will be how much it moved since this one
### 常用手势:
- UIPinchGestureRecognizer
var scale: CGFloat // not read-only (can reset) var velocity: CGFloat { get } // scale factor per second
- UIRotationGestureRecognizer
var rotation: CGFloat // not read-only (can reset); in radians var velocity: CGFloat { get } // radians per second
- UISwipeGestureRecognizer
Set up the direction and number of fingers you want, then look for .Recognized var direction: UISwipeGestureRecoginzerDirection // which swipes you want var numberOfTouchesRequired: Int // finger count
- UITapGestureRecognizer
Set up the number of taps and fingers you want, then look for .Ended var numberOfTapsRequired: Int // single tap, double tap, etc. var numberOfTouchesRequired: Int // finger count 
### Demo: Happiness pinch and pan
**FaceView Gestures**
Add a gesture recognizer (pinch) to the FaceView to zoom in and out (control its own scale)
Add a gesture recognizer (pan) to the FaceView to control happiness (Model) in the Controller
```
@IBAction func readButton(sender: UIButton) { let defaults = NSUserDefaults.standardUserDefaults() if let name = defaults.stringForKey(userNameKeyConstant) { print(name) } }
记得当初进公司是在家自学了3个月 iOS 无果,准备一边上班一边继续自学,现在看来多么傻的一个决定,既然不想做 IT 技术支持,就不要做。因为实际上很累,一天下来,偶尔还要加班,完全没有精力晚上在学习。当然只是一部分原因,最主要的阻碍是我自律很差,完全不适合自学。早早的应该3年前和老爸去咨询 IT 开发培训的时候,就该入学的。也不至于毕业3年,一事无成。