触摸事件总结
来源:互联网 发布:app教育收费软件 编辑:程序博客网 时间:2024/05/19 13:07
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
0 0
- iOS触摸事件总结
- 触摸事件总结
- Android触摸事件总结
- Android触摸事件总结
- 触摸事件分发机制总结
- 监听触摸事件 总结-----UIGestureRecognizer
- 移动端触摸事件总结
- ios触摸事件响应链个人总结
- Android触摸事件分发机制总结
- 【Android】触摸事件相关方法总结
- android 触摸事件的处理与总结
- 触摸事件
- 触摸事件
- 触摸事件
- 触摸事件
- 触摸事件
- 触摸事件
- 触摸事件
- 在VC中运用mkdir函数创建多级目录
- HashMap实现原理分析
- eclipse luna maven搭建spring mvc
- Java 读取Property
- POJ 2689 Prime Distance
- 触摸事件总结
- SpeedyCloud李孟:CDN系统中的DNS设计与开发
- 热门搜索不规则Textview FlowLayout
- hdu2046
- 使用Structs标签处理带有html标签元素的字符串
- 在JS方法中返回多个值的方法
- Hive学习3_错误:hive startup -[ERROR] Terminal initialization failed; falling back to unsupported
- 博客已迁移新地址
- java实现MD5加密