mnort9
mnort9

Reputation: 1820

Animating the display of a view on button press

I'd like to animate the display of a view when a button is pressed. When the button is pressed, the button will animate by increasing the x origin by ~150px.

The tricky part...

As the button slides to the right, a view should animate into display as if it is being pulled by the button. The animation will take place roughly in the middle of the screen, so I cannot simply set the initial origin of the view off the screen and animate it back on.

How do I accomplish this type of animation?

enter image description here enter image description here enter image description here

Upvotes: 0

Views: 63

Answers (2)

CSmith
CSmith

Reputation: 13458

Use CAAnimationGroup for your two View animations. The button animation is a simple translation. The View you could accomplish with a scale or alpha animation combined with a translation (e.g. scale from 0 to full size, or alpha from 0 to 1, to make the view appear)

Upvotes: 0

iSofTom
iSofTom

Reputation: 1718

Add a clear view with the clipToBounds set to YES and with for frame the final frame of you view with the stars. Then you just have to put your view with the stars in that clear view, shift it to the left, animate the x origin, and enjoy !

Upvotes: 1

Related Questions