单试图控制器——6种基本触摸手势
来源:互联网 发布:一拍两散林夕 知乎 编辑:程序博客网 时间:2024/06/05 18:47
定义部分
//1.轻拍手势
// UITapGestureRecognizer *tapGesture = [[UITapGestureRecognizer alloc]initWithTarget:self action:@selector(changViewBackgroundColor:)];
// tapGesture.numberOfTapsRequired = 2;//需要点击两次触法
// tapGesture.numberOfTouchesRequired = 2;//需要两根手指点击触法
// [aView addGestureRecognizer:tapGesture];
//2.长按手势
// UILongPressGestureRecognizer *longPerss = [[UILongPressGestureRecognizer alloc]initWithTarget:self action:@selector(changViewBackgroundColor:)];
// longPerss.minimumPressDuration = 2.0;//设置长按触发的最短时间
// [aView addGestureRecognizer:longPerss];
//长按手势在结束的时候会再次调用该方法,设置state值设为只在开始触法时调用该方法。
// if (tap.state == UIGestureRecognizerStateBegan)
//3.轻扫手势
// UISwipeGestureRecognizer *swipeGesture = [[UISwipeGestureRecognizer alloc]initWithTarget:self action:@selector(changViewBackgroundColor:)];
// swipeGesture.direction = UISwipeGestureRecognizerDirectionUp;//设置触法的方向为从下到上,初始为从左至右
// [aView addGestureRecognizer:swipeGesture];
//4.拖动手势
// UIPanGestureRecognizer *panGesture = [[UIPanGestureRecognizer alloc]initWithTarget:self action:@selector(panAction:)];
// [aView addGestureRecognizer:panGesture];
//5.捏合手势
// UIPinchGestureRecognizer *pinchGesture = [[UIPinchGestureRecognizer alloc]initWithTarget:self action:@selector(pinchAction:)];
// [aView addGestureRecognizer:pinchGesture];
//6.旋转手势
UIRotationGestureRecognizer *rotationGesture = [[UIRotationGestureRecognizer alloc]initWithTarget:self action:@selector(rotationAction:)];
[aView addGestureRecognizer:rotationGesture];
实现部分
//- (void)changViewBackgroundColor:(UISwipeGestureRecognizer *)tap
//{
// UIView *aView = tap.view;
// aView.backgroundColor = [UIColor colorWithRed:arc4random() % 256 / 255.0 green:arc4random() % 256 / 255.0 blue:arc4random() % 256 / 255.0 alpha:1.0];
// NSLog(@"tap");
//}
------------------------------------------------------------------------我是分割线---------------------------------------------------------------------
//- (void)panAction:(UIPanGestureRecognizer *)panGesture
//{
// //获得的偏移量是基于手指触摸初始点的偏移量
// CGPoint offsetPoint = [panGesture translationInView:panGesture.view];
// NSLog(@"offset point = %@",NSStringFromCGPoint(offsetPoint));
// //更改View的transform
// panGesture.view.transform = CGAffineTransformMakeTranslation(offsetPoint.x, offsetPoint.y);
//}
------------------------------------------------------------------------我是分割线---------------------------------------------------------------------
//- (void)pinchAction:(UIPinchGestureRecognizer *)pinch
//{
// NSLog(@"scale = %f",pinch.scale);
// //让View缩放
// pinch.view.transform = CGAffineTransformMakeScale(pinch.scale, pinch.scale);
//}
------------------------------------------------------------------------我是分割线---------------------------------------------------------------------
- (void)rotationAction:(UIRotationGestureRecognizer *)rotation
{
NSLog(@"rotation = %f",rotation.rotation);
//让View旋转
rotation.view.transform = CGAffineTransformMakeRotation(rotation.rotation);
}
- 单试图控制器——6种基本触摸手势
- iOS触摸手势——UIGestureRecognizer
- iOS——触摸事件与手势
- iOS触摸手势——UITouch
- iOS触摸手势——UITouch
- iOS触摸手势——UIGestureRecognizer
- iOS开发————触摸与手势
- iOS学习笔记—— 触摸及手势
- Hammer.js——移动设备触摸手势
- 触摸手势
- 触摸手势
- 70个jquery触摸事件插件——支持手势触摸!
- 试图控制器。生命周期UIViewController
- iOS试图控制器
- UI03_UIViewController试图控制器
- UI07_导航试图控制器
- Android手势识别01——基本手势的处理
- YH2000—C单门禁控制器
- 全文索引--学习篇
- nyoj题目48:小明的调查作业
- 关于在SSH框架整合时,使用hql语句查询出现 XXX is not mapped 的问题
- PIL Image模块 show函数无法正常显示图片
- ggplot2 2.0 标度(坐标轴,图例修改)
- 单试图控制器——6种基本触摸手势
- 气泡随机分布界面的实现
- shp2pgsql批量导入数据.cmd
- java8新特性
- 微信里经常看到的滑动翻页效果,slide,翻页slide
- tsung日志文件说明
- leetcode-countPrimes
- linux下查看负载均衡的两种方法
- 如何写分层驱动(复杂的字符驱动)----以lcd驱动为例