我的iOS学习历程 - 手势
来源:互联网 发布:用友u8软件介绍 编辑:程序博客网 时间:2024/06/05 00:59
我们在手机上可以用很多手势来触发不同的操作,今天就是学习怎样去添加手势
添加手势步骤
- 初始化手势 添加手势触发调用的方法
- 把手势添加到视图上
- 释放手势
1.长按
UILongPressGestureRecognizer *longPress = [[UILongPressGestureRecognizer alloc] initWithTarget:self action:@selector(longPressAction:)];// 设置长按时间 longPress.minimumPressDuration = 2.0; [imageView addGestureRecognizer:longPress]; [longPress release];
2.旋转
UIRotationGestureRecognizer *rotation = [[UIRotationGestureRecognizer alloc] initWithTarget:self action:@selector(rotationAciton:)]; [imageView addGestureRecognizer:rotation]; [rotation release];
3.捏合
UIPinchGestureRecognizer *pinch = [[UIPinchGestureRecognizer alloc] initWithTarget:self action:@selector(pinchAciton:)]; [imageView addGestureRecognizer:pinch]; [pinch release];
4.平移
UIPanGestureRecognizer *pan = [[UIPanGestureRecognizer alloc] initWithTarget:self action:@selector(panAction:)]; [imageView addGestureRecognizer:pan]; [pan release];
5.轻扫
UISwipeGestureRecognizer *swipe = [[UISwipeGestureRecognizer alloc] initWithTarget:self action:@selector(swipeAction:)]; swipe.direction = UISwipeGestureRecognizerDirectionLeft; [imageView addGestureRecognizer:swipe]; [swipe release];
6.边缘扫
UIScreenEdgePanGestureRecognizer *screenEdgePan = [[UIScreenEdgePanGestureRecognizer alloc] initWithTarget:self action:@selector(screenEdgePanAction:)];// 设置下从哪个边缘开始扫 screenEdgePan.edges = UIRectEdgeRight; [imageView addGestureRecognizer:screenEdgePan]; [screenEdgePan release];
每个手势添加的方法可以在下面自己写例如
实现轻拍方法:
- (void)tapAction:(UITapGestureRecognizer *)tap{ NSLog(@"你拍我了, 很轻"); UIImageView *imageView = (UIImageView *)tap.view; imageView.image = [UIImage imageNamed:@"Highlighted"];}
这就是我们的手势学习了
0 0
- 我的iOS学习历程 - 手势
- 我的iOS学习历程 - UITextField UIButton
- 我的iOS学习历程 - 自定义视图
- 我的iOS学习历程 - MVC模式
- 我的iOS学习历程 - TargetAction
- 我的iOS学习历程 - UISegmentedControl
- 我的iOS学习历程 - UITabBarViewController
- 我的iOS学习历程 - UICollection详解
- 我的iOS学习历程 - NSCalendar详解
- 我的学习历程
- 我的iOS学习历程 - UITableView(数据model的使用)
- 我的iOS学习历程 - UITableView的编辑
- 我的iOS学习历程 - UITableView的高级使用
- 我的iOS学习历程 - OC第一天
- 我的iOS学习历程 - OC第二天
- 我的iOS学习历程 - OC第三天
- 我的iOS学习历程 - OC第四天
- 我的iOS学习历程 - OC第五天
- [CodeForces 593D]Happy Tree Party[LCA][路径压缩]
- delphi 做了个DLL
- Android 对Android客户端与服务端传递的Json数据进行加密、解密操作
- thinkphp自动跳到首页 --开启域名部署/子域名部署/泛域名部署/IP访问部署
- C++类的几个细节:友元和默认构造
- 我的iOS学习历程 - 手势
- Android内存优化大全
- 理解互斥量和信号量
- php中curl的详细解说
- 猫猫学iOS之安装cocoapods
- php中curl的详细解说
- Android Builder模式分析(链式调用)
- expect用法
- 1103. Integer Factorization (30)