當一根或多根手指在螢幕上移動或拖曳的手勢稱為Pan手勢,

出發後由傳進來的參數可以得到每根手指的位置座標。

 程式碼如下:

#import "ViewController.h"

@interface ViewController ()

@end

@implementation ViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    // Do any additional setup after loading the view, typically from a nib.
}

- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}


-(IBAction)panGesture:(UIPanGestureRecognizer  *)sender
{
    for (int i = 0; i < sender.numberOfTouches; i++)
    {
        CGPoint point = [sender locationOfTouch:i inView:sender.view];
        NSLog(@"the %d finger located at %@", (i+1), NSStringFromCGPoint(point));
        
    }
}
@end

 執行結果:

2015-08-26 21:58:51.902 panGesture[12031:2203560] the 1 finger located at {252, 342}
2015-08-26 21:58:51.920 panGesture[12031:2203560] the 1 finger located at {252, 340}
arrow
arrow

    文章標籤

    iOS Pan gesture

    全站熱搜

    Will 發表在 痞客邦 留言(0) 人氣()