我想要使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