UIImage In random positions on screen.

Discussion in 'iOS Programming' started by uaecasher, Jul 2, 2010.

  1. macrumors 65816

    uaecasher

    Joined:
    Jan 29, 2009
    Location:
    Stillwater, OK
    #1
    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.
     
  2. macrumors member

    MacKeeper-fan

    Joined:
    Jun 30, 2010
    #2
    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.
     

Share This Page