touch move
touch end
移动程序中的view两个方式:1、transform
2、中心点
//
// SCHView.m
// touchSCHEvent
//
// Created by tianshangrenjian on 15/6/29.
// Copyright (c) 2015年 tianshangrenjian. All rights reserved.
//
#import "SCHView.h"
@implementation SCHView
/*
// Only override drawRect: if you perform custom drawing.
// An empty implementation adversely affects performance during animation.
- (void)drawRect:(CGRect)rect {
// Drawing code
}
*/
/*
鼠标在其上点击时触发的事件
*/
- (void)touchesBegan:(NSSet *)touches withEvent:(UIEvent *)event
{
NSLog(@"%zd",touches.count);
NSLog(@" 鼠标在其上点击时触发的事件");
}
/*
鼠标在其上移动时触发的事件
*/
- (void)touchesMoved:(NSSet *)touches withEvent:(UIEvent *)event
{
NSLog(@"鼠标在其上移动时触发的事件");
UITouch *touch=[touches anyObject];
CGPoint prevPoint=[touch previousLocationInView:touch.view];
CGPoint currentPoint=[touch locationInView:touch.view];
CGPoint centerPoint=touch.view.center;
centerPoint.x+=currentPoint.x- prevPoint.x;
centerPoint.y+=currentPoint.y- prevPoint.y;
// touch.view.center=currentPoint;
touch.view.center=centerPoint;
}
/*
鼠标在离开其上的时触发的事件
*/
- (void)touchesEnded:(NSSet *)touches withEvent:(UIEvent *)event
{
NSLog(@"鼠标在离开其上的时触发的事件");
}
@end