1

I have a UIViewController`s view on which I have a background image of cloud image. I am continuosly moving the image by keeping the imageview inside a scroll view and then scrolling the scrollview horizontally enabled with a NSTimer. This perfectly gives a picture of a moving cloud. Now , I have three UIButtons on the view . These are not in the scroll view. I want to very slowly animate these three buttons around their center randomly in such a way that they look like floating in the moving cloud. Could someone help me with this?

iOS_Passion
  • 788
  • 1
  • 7
  • 17

1 Answers1

0

You will need to learn to move UIView's on your own. You will want to create a subclass of UIView, add subviews to it, and you can change the subview's location like so:

mySubview.center = CGPointMake(xCoordinate, yCoordinate);

(Keep in mind the origin is in the upper lefthand corner and y increases downward)

This is the simplest way to move your UIView's although you can use CGAffineTransform along with the mySubview.frame property.

As for getting random numbers, use arc4random().

Almost everything you see in an app is a subclass of UIView, and that includes UIButton, UIScrollView, and UIImageView. You should be able to achieve the desired effect from here. I would also recommend you rewrite your moving clouds to use a custom subview rather than hijacking a UIScrollView.

Community
  • 1
  • 1
WolfLink
  • 3,308
  • 2
  • 26
  • 44