0

我喜欢垂直拖动这个对象而不是水平拖动,现在就是这样:

- (void)touchesMoved:(NSSet *)touches withEvent:(UIEvent *)event {
    UITouch *touch = [[event allTouches] anyObject];
    CGPoint location = [touch locationInView:touch.view];
    if (CGRectContainsPoint(myObject.frame, location)){
    CGPoint xLocation = CGPointMake(location.x, myObject.center.y);
    myObject.center = xLocation;
    }
}
4

1 回答 1

1
CGPoint yLocation = CGPointMake(myObject.center.x, location.y);
myObject.center = yLocation;
于 2010-05-08T11:45:32.133 回答