常见手势使用
来源:互联网 发布:最新淘宝店铺教程视频 编辑:程序博客网 时间:2024/06/06 17:55
常用的有以下几种
敲击UITapGestureRecognizer捏合(一般用于缩放)UIPinchGestureRecognizer拖拽UIPanGestureRecognizer轻扫UISwipeGestureRecognizer旋转UIRotationGestureRecognizer长按UILongPressGestureRecognizer
- (void)addTap{ UITapGestureRecognizer *tap = [[UITapGestureRecognizer alloc]initWithTarget:self action:@selector(tap:)]; tap.numberOfTapsRequired = 2;//点击次数 [self.imageView addGestureRecognizer:tap]; UILongPressGestureRecognizer *longPress = [[UILongPressGestureRecognizer alloc]initWithTarget:self action:@selector(longpress:)]; [self.imageView addGestureRecognizer:longPress]; UISwipeGestureRecognizer *swipe = [[UISwipeGestureRecognizer alloc]initWithTarget:self action:@selector(swipe:)]; //设置轻扫方向 swipe.direction = UISwipeGestureRecognizerDirectionUp; [self.imageView addGestureRecognizer:swipe]; UIRotationGestureRecognizer *rotation = [[UIRotationGestureRecognizer alloc]initWithTarget:self action:@selector(rotation:)]; [self.imageView addGestureRecognizer:rotation]; UIPinchGestureRecognizer *pinch = [[UIPinchGestureRecognizer alloc]initWithTarget:self action:@selector(pinch:)]; [self.imageView addGestureRecognizer:pinch]; UIPanGestureRecognizer *pan = [[UIPanGestureRecognizer alloc]initWithTarget:self action:@selector(pan:)]; [self.imageView addGestureRecognizer:pan];}- (void)tap:(UITapGestureRecognizer *)tap{ NSLog(@"%s",__func__);}- (void)longpress:(UILongPressGestureRecognizer *)longpress{ //长按一般有俩种,按下和弹起(一般用弹起) if(longpress.state == UIGestureRecognizerStateEnded){ NSLog(@"%s",__func__); }}- (void)swipe:(UISwipeGestureRecognizer *)swipe{ NSLog(@"%s",__func__);}- (void)rotation:(UIRotationGestureRecognizer *)rotat{ NSLog(@"%s",__func__); self.imageView.transform = CGAffineTransformRotate(self.imageView.transform,rotat.rotation); //默认传递的旋律的角度都是相对于最开始的位置 //复位 rotat.rotation = 0;}- (void)pinch:(UIPinchGestureRecognizer *)pinch{ NSLog(@"%s",__func__); self.imageView.transform = CGAffineTransformScale(self.imageView.transform, pinch.scale,pinch.scale); //复位,缩放比例为1 pinch.scale = 1;}-(void)pan:(UIPanGestureRecognizer *)pan{ NSLog(@"%s",__func__); //获取手势的移动,也就是相对于最开始的位置 CGPoint transP = [pan translationInView:self.imageView]; self.imageView.transform = CGAffineTransformTranslate(self.imageView.transform, transP.x, transP.y); //复位 [pan setTranslation:CGPointZero inView:self.imageView];}
阅读全文
0 0
- 常见手势使用
- iOS中得手势和触摸使用(常见)
- iOS 常见手势
- 常见手势添加
- iOS常见的手势
- 手势使用
- 手势使用
- 常见手势的响应事件
- 使用iOS手势UIGestureRecognizer
- 使用iOS手势UIGestureRecognizer
- 使用iOS手势UIGestureRecognizer
- 使用iOS手势UIGestureRecognizer
- 使用iOS手势UIGestureRecognizer
- 使用iOS手势UIGestureRecognizer
- 使用iOS手势UIGestureRecognizer
- 使用iOS手势UIGestureRecognizer
- 使用iOS手势UIGestureRecognizer
- 使用iOS手势UIGestureRecognizer
- Xshell 出现中文乱码,你需要这样做!
- 关于move_uploaded_file()出错的问题
- C语言局部变量与全局变量
- 第九天实训!!!
- 太乐地图下载器 V5.0.5 破解版
- 常见手势使用
- 86. Partition List
- vue 学习 1
- IT优先级2017:技术领导者仍然投资于云选项
- 快速排序
- String类型转 Map
- Hadoop调试:Exception in thread "main"java.lang.UnsatisfiedLinkError
- apscheduler modify_job能否修改更多参数
- leetcode分类题解