0
我在我的應用程序中實現了一個可拖動的UIView。代碼我工作得很好,但我想設置一個限制區UIView可以移動。如何設置最小和最大y值?
我的代碼:
-(void) touchesBegan:(NSSet *)touches withEvent:(UIEvent *)event
{
UITouch *touch = [[event allTouches] anyObject];
if([touch view] == camview)
{
CGPoint location = [touch locationInView:self.view;
startX = camview.center.x;
startY= location.y - camview.center.y;
}
}
- (void) touchesMoved:(NSSet *)touches withEvent:(UIEvent *)event{
UITouch *touch = [[event allTouches] anyObject];
if([touch view] == camview)
{
CGPoint location = [touch locationInView:self.view];
location.y =location.y - startY;
location.x = startX;
camview.center = location;
}
}
所以,我怎麼可以設置最小和最大y值UIView的可拖動?
謝謝!
太謝謝你了(! – Grace 2012-02-08 03:24:11