Touch Move

- (void)touchesBegan:(NSSet *)touches withEvent:(UIEvent *)event

{

    if (!dragEnable) {

        return;

    }

    UITouch *touch = [touches anyObject];

    

    beginPoint = [touch locationInView:self];

    

}


- (void)touchesMoved:(NSSet *)touches withEvent:(UIEvent *)event

{

    if (!dragEnable) {

        return;

    }

    UITouch *touch = [touches anyObject];

    

    CGPoint nowPoint = [touch locationInView:self];

    

    float offsetX = nowPoint.x - beginPoint.x;

    float offsetY = nowPoint.y - beginPoint.y;

    

    self.center = CGPointMake(self.center.x + offsetX, self.center.y + offsetY);

}



- (void)touchesEnded:(NSSet *)touches withEvent:(UIEvent *)event

{

}



- (void)touchesCancelled:(NSSet *)touches withEvent:(UIEvent *)event

{

}

posted @ 2012-12-06 15:31  废弃账号  阅读(84)  评论(0编辑  收藏  举报