我有两个视图和一个viewcontroller:一个包含带图像的UIImageView,第二个包含touchesBegan和touchesEnded方法:
- (void)touchesBegan:(NSSet *)touches withEvent:(UIEvent *)event {
[viewcontroller moveMethod];
}
如何使moveMethod方法使动画(例如移动x轴)平滑重复,直到我停止推动视图?
答案 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];