views:

583

answers:

2

Hi I have not done any animation stuff with iphone development so far.

Can anybody help me how to make UIbutton move from right to left when view is loaded?

I want to generate effect like that : when view is loaded, the button appears moving from right end to left & stops at its place. Is it possible?

Any help regarding this animation stuff is appreciated. Please help with some sample if available.

Thanks in advance.

+1  A: 

in your viewDidAppear:(BOOL)animated method you can change frame of your button inside animation block. so you'll see what you want. Check documentation about animations in UIView class reference. The simpliest animation block will be like that(sorry, i have no mac nearby right now, so code may not be working just after copy and paste)

[UIView beginAnimations:nil context:nil];
[UIView setAnimationDuration:1.0f];
[myButton setFrame:newFrame];
[UIView commitAnimations];
Morion
Thanks Morion I got the ans.
Rambo
+1  A: 

Just to make it even slicker, I would suggest not changing the UIView's frame but its center;

CGPoint newLeftCenter = CGPointMake( 20.0f + myButton.frame.size.width / 2.0f, myButton.center.y);
[UIView beginAnimations:nil context:nil]; 
[UIView setAnimationDuration:1.0f];
myButton.center = newLeftCenter;
[UIView commitAnimations];
Till
Thanks Till for your response.
Rambo