文章搬运来源:blog.csdn.net/Calvin_zhou…面试
做者:PGzxc(若有侵权,联系做者,当即删除)markdown
对iOS开发感兴趣,能够看一下做者的iOS交流群:812157648,你们能够在里面吹水、交流相关方面的知识,群里还有我整理的有关于面试的一些资料,欢迎你们加群,你们一块儿开车app
-(void)touchBegan:(NSSet *)touches withEvent:(UIEvent *)event;
-(void)touchMoved:(NSSet *)touches withEvent:(UIEvent *)event;
-(void)touchEnded:(NSSet *)touches withEvent:(UIEvent *)event;
-(void)touchCancelled:(NSSet *)touches withEvent:(UIEvent *)event;
复制代码
-(void)motionBegan:(UIEventSubtype)motion withEvent:(UIEvent *)event;
-(void)motionEnded:(UIEventSubtype)motion withEvent:(UIEvent *)event;
-(void)motionCancelled:(UIEventSubtype)motion withEvent:(UIEvent *)event;
复制代码
-(void)remoteControlReceivedWithEvent:(UIEvent *)event;
复制代码
@property(nonatomic,readonly,retain)UIWindow *window;
复制代码
@property(nonatomic,readonly,retain)UIView *view;
复制代码
@property(nonatomic,readonly)NSUInteger tapCount;
复制代码
@property(nonatomic,readonly)NSTimeInterval timestamp;
复制代码
@property(nonatomic,readonly)UITouchPhase phase;
复制代码
typedef NS_ENUM(NSInteger, UITouchPhase) {
UITouchPhaseBegan, // whenever a finger touches the surface.
UITouchPhaseMoved, // whenever a finger moves on the surface.
UITouchPhaseStationary, // whenever a finger is touching the surface but hasn't moved since the previous event.
UITouchPhaseEnded, // whenever a finger leaves the surface.
UITouchPhaseCancelled,
复制代码
//触摸移动
- (void)touchesMoved:(NSSet<UITouch *> *)touches withEvent:(UIEvent *)event
{
UITouch *touch=[touches anyObject];
//获取当前的位置
CGPoint current=[touch locationInView:self];
CGPoint pre=[touch previousLocationInView:self];
//x轴的偏移量
CGFloat offsetX=current.x-pre.x;
CGFloat offsetY=current.y-pre.y;
CGPoint center=self.center;
center.x+=offsetX;
center.y+=offsetY;
self.center=center;
//NSLog(@"%d",touch.phase);
//NSLog(@"%s---%p",__func__,touch);
}
复制代码