//捏合手势
UIPinchGestureRecognizer *pin = [[UIPinchGestureRecognizer alloc]initWithTarget:self action:@selector(run:)];
[_vieww addGestureRecognizer:pin];
//旋转手势
UIRotationGestureRecognizer *rol = [[UIRotationGestureRecognizer alloc]initWithTarget:self action:@selector(rotationg:)];
[_vieww addGestureRecognizer:rol];
//拖的手势
UIPanGestureRecognizer *pan = [[UIPanGestureRecognizer alloc]initWithTarget:self action:@selector(pan:)];
[_vieww addGestureRecognizer:pan];
//长按手势
UILongPressGestureRecognizer *longp = [[UILongPressGestureRecognizer alloc]initWithTarget:self action:@selector(longf:)];
[_vieww addGestureRecognizer:longp];
}
-(void)longf:(UILongPressGestureRecognizer *)sender
{
CGFloat scale ;
if (_vieww.tag ==0) {
scale =2.0;
_vieww.tag = 1;
}
else
{
scale =0.5;
_vieww.tag =0;
}
sender.view.transform = CGAffineTransformScale(sender.view.transform,scale,scale);
}
-(void)run:(UIPinchGestureRecognizer *)sender
{
sender.view.transform = CGAffineTransformScale(sender.view.transform, sender.scale,sender.scale );
sender.scale = 1.0f;
}
-(void)rotationg:(UIRotationGestureRecognizer *)sender
{
sender.view.transform = CGAffineTransformRotate(sender.view.transform, sender.rotation );
sender.rotation = 0.0f;
}
-(void)pan:(UIPanGestureRecognizer *)sender
{
if (sender.state == UIGestureRecognizerStateChanged) {
[_vieww setCenter:[sender locationInView:self.view]];
}else if (sender.state == UIGestureRecognizerStateEnded)
{
_vieww.backgroundColor = [UIColor yellowColor];
}
}