我想要使UIImageview动画在屏幕上随机移动。对于一个UIImageView,它工作正常。但是对于两个或更多的对象它不起作用。谁能帮我?在屏幕上随机移动两个或多个对象
-(void)animationLoop:(NSString *)animationID finished:(NSNumber *)finished context:(void *)context {
[UIView beginAnimations:nil context:nil];
[UIView setAnimationDuration:1];
CGFloat x = (CGFloat) (arc4random() % (int) self.view.bounds.size.width);
CGFloat y = (CGFloat) (arc4random() % (int) self.view.bounds.size.height);
CGPoint squarePostion = CGPointMake(x, y);
image.center = squarePostion;
[UIView setAnimationDelegate:self];
[UIView setAnimationDidStopSelector:@selector(animationLoop:finished:context:)];
[UIView commitAnimations];
}
在此先感谢
显示迄今为止所做的工作。 – 2012-04-10 08:51:51
是的,请添加相关的代码片段 – giorashc 2012-04-10 08:56:08
我已经添加了我写的代码。 – Priya 2012-04-10 09:00:30