NSScreencast Episode #47 Gesture Recognizers
Gesture Recognizers - NSScreencast
tapした場所に画像を表示させる、移動、拡大縮小、回転
- common
- initWithTarget:self, action:@selector(onViewDoubleTap:)
- [self.view addGestureRecognizer:tapRecognizer];
- UITapGestureRecognizer
- tapRecognizer.numberOfTapsRequired = 2;
- onViewDoubleTap
- CGPoint touchCenter = [tap locationInView:self.view];
- effect
- CGAffineTransformRotate(imageView.transform, angle);
- animateWithDuration:0.25 animations
- imageView.layer
- .border
- .shadow
- shadowOpacity
- CGMutablePathRef shadowPath = CGPathCreateMutable();
- CGPathRelease(shadowPath);
- UIPanGestureRecognizer
- onPan
- [pan translationInView:self.view];
- pan.view.center;
- pan=drag?
- onPan
- UIPinchGestureRecognizer
- onPinch
- CGFloat scale = [pinch scale];
- [pinch setScale:1];
- onPinch
- UIRotationGestureRecognizer
- onRotate
- CGFloat angle = [rotation rotation];
- [rotation setRotation:0];
- onRotate
- UISwipeGestureRecognizer
- swipeRecognizer.direction = UISwipeGestureRecognizerDirectionDown;
- simultaneous gestures
- don't work together
- pinch and rotate
- swipe down and pan down
- shouldRecognizeSimultaneouslyWithGestureRecognizer
- pinchRecognizer.delegate = self;
- gestureRecognizerShouldBegin
- if ([gestureRecognizer isKindOfClass:[UISwipeGestureRecognizer class]]) {
- don't work together
- simulator
- option -> pinch
- option + shift -> pinch and move