触摸事件总结
2016-01-24 18:47
204 查看
1.触摸事件常用方法:
- (void)touchesBegan:(NSSet *)touches withEvent:(UIEvent *)event; - (void)touchesMoved:(NSSet *)touches withEvent:(UIEvent *)event; - (void)touchesEnded:(NSSet *)touches withEvent:(UIEvent *)event; - (void)touchesCancelled:(NSSet *)touches withEvent:(UIEvent *)event; //返回手指当前所在的位置。 - (CGPoint)locationInView:(UIView *)view; //返回前一个触摸点的位置 - (CGPoint)previousLocationInView:(UIView *)view;
2.UITouch的一些属性
//触摸产生时所处的窗口 @property(nonatomic,readonly,retain) UIWindow *window; //触摸产生时所处的视图 @property(nonatomic,readonly,retain) UIView *view; //短时间内点按屏幕的次数,可以根据tapCount判断单击、双击或更多的点击 @property(nonatomic,readonly) NSUInteger tapCount; //记录了触摸事件产生或变化时的时间,单位是秒 @property(nonatomic,readonly) NSTimeInterval timestamp; //当前触摸事件所处的状态 @property(nonatomic,readonly) UITouchPhase phase;
3.UIEvent属性
事件类型 @property(nonatomic,readonly) UIEventType type; @property(nonatomic,readonly) UIEventSubtype subtype; 事件产生的时间 @property(nonatomic,readonly) NSTimeInterval timestamp;
4.利用Category对UIView进行方法扩展,实现截屏功能:
#import "UIImage+YF.h" @implementation UIImage (YF)//这是一种语法,是对某个类方法的扩充。 + (instancetype)captureWithView:(UIView *)view { // 1.开启上下文 UIGraphicsBeginImageContextWithOptions(view.frame.size, NO, 0.0); // 2.将控制器view的layer渲染到上下文 [view.layer renderInContext:UIGraphicsGetCurrentContext()]; // 3.取出图片 UIImage *newImage = UIGraphicsGetImageFromCurrentImageContext(); // 4.结束上下文 UIGraphicsEndImageContext(); return newImage; } @end
相关文章推荐
- JavaHello_记事本程序
- 【Hibernate】Hibernate的集合映射(Set、List、Array、Map、Bag)
- 学习aiax(javascript)--页面无刷新用ajax检查用户名是否已注册(POST方式)
- USACO-Section 3.1-PROB Contact
- 人生中第一篇论文,虽然是二作,也记录一下
- C语言指针要点
- flock shell script 使用速记
- 学习aiax(javascript)--页面无刷新更新ajax更新时间
- Androidx学习笔记(21)-- SQLite 事务
- HDU3572_Task Schedule(网络流最大流)
- POJ Kaka's Matrix Travels (最大费用最大流)
- [leetcode]Unique Paths
- Android系统进程间通信(IPC)机制Binder中的Client获得Server远程接口过程源代码分析
- 各种 django 静态文件的配置总结【待续】
- ZOJ 1005 jugs
- 【未完】yum源解析,配置
- hive 配置mysql元数据库
- Python
- HDU-4983-Goffi and GCD【数论】【欧拉函数】
- 【IOS学习基础】OC类的相关