手势(常见手势)
//所有手势,都在控制器中添加
//轻点
UITapGestureRecognizer *tap = [[UITapGestureRecognizer alloc] initWithTarget:(self) action:@selector(s:)];
[imV addGestureRecognizer:tap];
//设置点击几下
tap.numberOfTapsRequired = 1;
//设置几个手指
tap.numberOfTouchesRequired = 2;
//长按
//UILongPressGestureRecognizer
UILongPressGestureRecognizer *lp = [[UILongPressGestureRecognizer alloc] initWithTarget:self action:@selector(s:)];
//按动时间
lp.minimumPressDuration = 2.0;
[imV addGestureRecognizer:lp];
//轻扫
//UISwipeGestureRecognizer
UISwipeGestureRecognizer *swi = [[UISwipeGestureRecognizer alloc]initWithTarget:self action:@selector(s:)];
swi.numberOfTouchesRequired = 1;
//能上能下
swi.direction = UISwipeGestureRecognizerDirectionDown|UISwipeGestureRecognizerDirectionUp;
[imV addGestureRecognizer:swi];
//拖动
// UIPinchGestureRecognizer
UIPanGestureRecognizer *pan = [[UIPanGestureRecognizer alloc] initWithTarget:self action:@selector(s:)];
pan.minimumNumberOfTouches = 1;
[imV addGestureRecognizer:pan];
//捏合
//UIPinchGestureRecognizer
UIPinchGestureRecognizer *pin = [[UIPinchGestureRecognizer alloc] initWithTarget:self action:@selector(g:)];
[imV addGestureRecognizer:pin];
//捏合方法
-(void)g:(UIPinchGestureRecognizer *)sender
{
sender.view.transform = CGAffineTransformMakeScale(sender.scale, sender.scale);
}
//旋转
// UIRotationGestureRecognizer
UIRotationGestureRecognizer *rota = [[UIRotationGestureRecognizer alloc] initWithTarget:self action:@selector(s:)];
[imV addGestureRecognizer:rota];
//旋转方法
-(void)s:(UIRotationGestureRecognizer *)sender
{
sender.view.transform = CGAffineTransformMakeRotation(sender.rotation);
}