我正在尝试制作一个滑块,用手指从左到右滑动图像。我想使用UIGestureRecognizer。为了这个目的我该如何做到这一点,每次手指移动时都会记下手指的坐标?
答案 0 :(得分:1)
您可以尝试这样的事情
-(void)viewDidLoad;
{
[super viewDidLoad];
UIPanGestureRecognizer* pgr = [[UIPanGestureRecognizer alloc]
initWithTarget:self
action:@selector(handlePan:)];
[self.panningView addGestureRecognizer:pgr];
}
-(void)handlePan:(UIPanGestureRecognizer*)pgr;
{
if (pgr.state == UIGestureRecognizerStateChanged) {
CGPoint center = pgr.view.center;
imageView.center = center;
}
}