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.
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];
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];
From top to bottom animation
CATransition *animation = [CATransition animation];
[animation setDuration:0.4];
[animation setType:kCATransitionPush];
[animation setSubtype:kCATransitionFromBottom];
[animation setTimingFunction:[CAMediaTimingFunction functionWithName:kCAMediaTimingFunctionEaseInEaseOut]];
[[TopButton layer] addAnimation:animation forKey:@"SwitchToDown"];
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With