现在的位置: 首页 > 综合 > 正文

Touch Move

2018年05月25日 ⁄ 综合 ⁄ 共 635字 ⁄ 字号 评论关闭

- (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

{

}

【上篇】
【下篇】

抱歉!评论已关闭.