iOS????????????
???????????? ???????[ 2014/11/18 11:19:32 ] ????????IOS ??????? ??????
???????????????????????????
?????????UIGestureRecognizerStateBegan
???????UIGestureRecognizerStateChanged
??????????UIGestureRecognizerStateEnded
?????????UIGestureRecognizerStateCancelled
????????UIGestureRecognizerStateFailed
????3.????????SwipeGestureRecognizer??
?????????????????????????????????????????? ?????????????????????????????????????????????????????
?????????????????????????????????????£?
????1 //??????????
????2 UISwipeGestureRecognizer *swipeGesture = [[UISwipeGestureRecognizer alloc] initWithTarget:self action:@selector(swipeGesture:)];
????3 //????????????
????4 swipeGesture.direction = UISwipeGestureRecognizerDirectionRight; //???????
????5 [self.view addGestureRecognizer:swipeGesture];
????6
????7 //??????????
????8 UISwipeGestureRecognizer *swipeGestureLeft = [[UISwipeGestureRecognizer alloc] initWithTarget:self action:@selector(swipeGesture:)];
????9 //????????????
????10 swipeGestureLeft.direction = UISwipeGestureRecognizerDirectionLeft; //???????
????11 [self.view addGestureRecognizer:swipeGestureLeft];
??????????????£?
1 //??????????????
2 -(void)swipeGesture:(id)sender
3 {
4 UISwipeGestureRecognizer *swipe = sender;
5 if (swipe.direction == UISwipeGestureRecognizerDirectionLeft)
6 {
7 //???????????????
8 }
9 if (swipe.direction == UISwipeGestureRecognizerDirectionRight)
10 {
11 //???????????????
12 }
13 }
14
????4.????????PinchGestureRecognizer??
???????????????
????1 //??????????
????2 UIPinchGestureRecognizer *pinchGesture = [[UIPinchGestureRecognizer alloc] initWithTarget:self action:@selector(pinchGesture:)];
????3 [self.view addGestureRecognizer:pinchGesture];
???????????????????????????????С??????
1 ////??????????????
2 -(void) pinchGesture:(id)sender
3 {
4 UIPinchGestureRecognizer *gesture = sender;
5
6 //???????
7 if (gesture.state == UIGestureRecognizerStateChanged)
8 {
9 //?????????scale???????????????
10 _imageView.transform = CGAffineTransformMakeScale(gesture.scale?? gesture.scale);
11 }
12
13 //????????
14 if(gesture.state==UIGestureRecognizerStateEnded)
15 {
16 [UIView animateWithDuration:0.5 animations:^{
17 _imageView.transform = CGAffineTransformIdentity;//???????α?
18 }];
19 }
20 }
????5.????????PanGestureRecognizer??
????????????????
????1 //??????????
????2 UIPanGestureRecognizer *panGesture = [[UIPanGestureRecognizer alloc] initWithTarget:self action:@selector(panGesture:)];
????3 [self.view addGestureRecognizer:panGesture];
????????????????????????translationInView???????????TouchesMoved?????????
????1 //???????
????2 -(void) panGesture:(id)sender
????3 {
????4 UIPanGestureRecognizer *panGesture = sender;
????5
????6 CGPoint movePoint = [panGesture translationInView:self.view];
????7
????8 //?????????????
????9 }
??????
???·???
??????????????????
2023/3/23 14:23:39???д?ò??????????
2023/3/22 16:17:39????????????????????Щ??
2022/6/14 16:14:27??????????????????????????
2021/10/18 15:37:44???????????????
2021/9/17 15:19:29???·???????·
2021/9/14 15:42:25?????????????
2021/5/28 17:25:47??????APP??????????
2021/5/8 17:01:11