iPhone UIView动画直到停止按下

时间:2011-07-07 12:52:03

标签: iphone uiview

我有两个视图和一个viewcontroller:一个包含带图像的UIImageView,第二个包含touchesBegan和touchesEnded方法:

- (void)touchesBegan:(NSSet *)touches withEvent:(UIEvent *)event {
    [viewcontroller moveMethod];
}

如何使moveMethod方法使动画(例如移动x轴)平滑重复,直到我停止推动视图?

1 个答案:

答案 0 :(得分:0)

尝试使用此代码在x轴上移动视图

CGRect frame=view.frame;
frame.origin.x=frame.origin.x+200;
[UIView beginAnimations:@"" context:nil];
[UIView setAnimationDuration:2];
[UIView setAnimationDelegate:self];    
view.frame=frame;
[UIView commitAnimations];