PDA

View Full Version : UIImage In random positions on screen.




uaecasher
Jul 2, 2010, 03:08 AM
Hello,

I want to keep changing the position of an image on screen randomly, not sure how make this, I searched around but didn't find something useful, any help would be much appreciated.



MacKeeper-fan
Jul 2, 2010, 03:24 AM
just call arc4random() for the coordinate center of the image.

something like:

myImage.center = CGRectPoint(arc4random() % 320, arc4random() % 480);

better put in some more maths into it, so that it caters for the width/height of the image.