#import "DragView.h"
@implementation DragView
-(void)touchesMoved:(NSSet *)touches withEvent:(UIEvent *)event{
CGPoint touchPoint = [[touches anyObject] locationInView:self];
CGPoint previousPoint = [[touches anyObject] previousLocationInView:self];
CGFloat xChange=touchPoint.x-previousPoint.x;
CGFloat yChange=touchPoint.y-previousPoint.y;
float newX=self.frame.origin.x+xChange;
float newY=self.frame.origin.y+yChange;
self.frame=CGRectMake(newX, newY, self.frame.size.width, self.frame.size.height);
}
@end
No comments:
Post a Comment