为了对子视图进行约束,我该怎么做?

时间:2014-03-02 01:29:45

标签: ios uitouch restriction touchesbegan touchesmoved

我不希望用户能够在屏幕上向上滑动超过2/3的项目。

我是否改变touchesBegan或touchesMoved?如果是这样,怎么样?

-(void)touchesBegan:(NSSet *)touches withEvent:(UIEvent *)event{
    UITouch* touch = [touches anyObject];
    returnLocation = [touch locationInView:self.superview];
    returnLocation.x += self.frame.size.width/2-startlocation.x;
    returnLocation.y += self.frame.size.width/2-startlocation.y;
}
-(void)touchesMoved:(NSSet *)touches withEvent:(UIEvent *)event{
    UITouch* touch = [touches anyObject];
    CGPoint currentLocation = [touch locationInView:self.superview];
    self.center = currentLocation;

0 个答案:

没有答案