手势操作 IOS

原创 2015年07月07日 17:42:40

- (void)loadView

 

{

    

    self.view=[[UIView alloc]initWithFrame:CGRectMake(20, 20, 300, 400)];

    self.view.backgroundColor=[UIColor redColor];

    

    imageView=[[UIImageView alloc]initWithFrame:CGRectMake(0, 0, 200, 300)];

    imageView.image=[UIImage imageNamed:@"h1.jpg"];

    imageView.tag=100;

    imageView.userInteractionEnabled=YES;

    

    [self.view addSubview:imageView];

    [imageView release];

    

    

    UITapGestureRecognizer* tapges=[[UITapGestureRecognizer alloc]initWithTarget:self action:@selector(tapImageView:)];

    tapges.numberOfTapsRequired=1;

    [imageView addGestureRecognizer:tapges];

    [tapges release];

    

    //长按

    UILongPressGestureRecognizer*pressges=[[UILongPressGestureRecognizer alloc]initWithTarget:self action:@selector(longImageView:)];

    [imageView addGestureRecognizer:pressges];

    [pressges release];

    //捏合

    UIPinchGestureRecognizer*pinchGRer=[[UIPinchGestureRecognizer alloc]initWithTarget:self action:@selector(pinchImageView:)];

    [imageView addGestureRecognizer:pinchGRer];

    [pinchGRer release];

    //旋转

    

    UIRotationGestureRecognizer*rotation=[[UIRotationGestureRecognizer alloc]initWithTarget:self action:@selector(rotationImageView:)];

    [imageView addGestureRecognizer:rotation];

    [rotation release];

    

    //清扫

    UISwipeGestureRecognizer*swipeGRer=[[UISwipeGestureRecognizer alloc]initWithTarget:self action:@selector(swipeImageView:)];

    

    [imageView addGestureRecognizer:swipeGRer];

    [swipeGRer release];

    

    //拖拽

    UIPanGestureRecognizer*panGRer=[[UIPanGestureRecognizer alloc]initWithTarget:self action:@selector(panImageView:)];

    [imageView addGestureRecognizer:panGRer];

    [panGRer release];

}

-(void)tapImageView:(UITapGestureRecognizer*)sender

{


}

-(void)longImageView:(UILongPressGestureRecognizer*)sender

{


}

-(void)pinchImageView:(UIPinchGestureRecognizer* )sender

{

    //imageView

}


-(void)rotationImageView:(UIRotationGestureRecognizer*)sender


{

    imageView.transform=CGAffineTransformMakeRotation(sender.rotation);

}

-(void)swipeImageView:(UISwipeGestureRecognizer*)sender

{

    NSString*imageName=[NSString stringWithFormat:@"hi.jpeg",arc4random()%20+1];

}

-(void) pantapImageView:(UIPanGestureRecognizer*)sender

{

    sPoint=[sender locationInView:imageView];

    if (sender.state==UIGestureRecognizerStateBegan) {

        sPoint=[sender locationInView:imageView];

    }

    CGPoint current=[sender locationInView:imageView];

    float disx=current.x-sPoint.x;

    float disy=current.y-sPoint.y;

    

    imageView.center=CGPointMake(imageView.center.x+disx, imageView.center.y+disy);

    

}

ios手势操作演示

  • 2014年12月24日 10:00
  • 140KB
  • 下载

多手势操作实现ios图文混排

  • 2014年07月07日 22:19
  • 2.06MB
  • 下载

iOS开发——仿Clear纯手势操作的UITableView

在Clear应用中,用户无需任何按钮,纯靠不同的手势就可以完成对ToDoItem的删除、完成、添加、移动。具体来说,功能上有左划删除,右划完成,点击编辑,下拉添加、捏合添加、长按移动。这里将这些功能实...

iOS7应用开发7:自定义视图、手势操作

1、视图: #屏幕上表示某一个矩形区域;某个视图只能有一个父视图,但是可能有多个子视图; #UIWindow:屏幕视图,在整个视图结构体系的最上层,仅适用于ios应用; #添加视图的函数: - (vo...

iOS UIGestureRecognizer(手势操作)~demo

//联系人:石虎  QQ: 1224614774昵称:嗡嘛呢叭咪哄 #import "ViewController.h" @interface ViewController () ...

iOS手势操作简介(一)

iOS中能够响应手势操作的类必须要继承自UIResponder,才能够处理手势响应操作。 默认继承了UIResponder的类有:UIApplication UIViewController UIV...

iOS 手势操作:拖动、捏合、旋转、点按、长按、轻扫、自定义

转载自:http://www.cnblogs.com/huangjianwu/p/4675648.html 1、UIGestureRecognizer 介绍 手势识别在 iOS 中...

iOS开发系列课程(08) --- 事件处理详解和手势操作

事件机制和手势操作无疑是实现用户交互的重要手段,iOS中的事件机制有着怎样的特点?如何处理长按、滑动、捏合等手势呢?让我们娓娓道来。...
内容举报
返回顶部
收藏助手
不良信息举报
您举报文章:手势操作 IOS
举报原因:
原因补充:

(最多只允许输入30个字)