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