Simple Animation
Here (In example 1) is simple animation code. That is straight forward and easy please read its step by step comment.
Example 1
---------------------------------------------------------------------------------
[UIView beginAnimations:nil context:nil]; //Animation Start
[UIView setAnimationDuration:0.70]; //How long animation is run.
[UIView setAnimationDelay:0.0]; //Is there any wait to perform animation.
[UIView setAnimationCurve:UIViewAnimationCurveEaseOut]; //Animation Type
//Your Code For Animating Element.
[UIView commitAnimations]; //End Animation
---------------------------------------------------------------------------------
Simple Animation Block
In example 2 its display simple animation block. That take only animation time and other element work as default for customize those element please refers other example.
Example 2
---------------------------------------------------------------------------------
[UIView animateWithDuration:1.0f animations:^{ //Your Code For Animating Element.
}];
---------------------------------------------------------------------------------
Animation With Completion Block
This(In example 3) is simple animation block that use when condition like wait until animation is done. In below example we create one animation block in that first line we its duration as 1 then start animation that mean animation is completed in 1 minute you can edit that as per your requirement. Then in second block , its call completion that mean that block execution when animation is completed in below case that call after 1 min.
Example : 3
---------------------------------------------------------------------------------
[UIView animateWithDuration:1.0
animations:^{
//Your Code For Animating Element.
}
completion:^(BOOL finished){
//Wait until above animation is done.
}];
---------------------------------------------------------------------------------
Animation With Completion Block and Other Parameter.
Example : 4
---------------------------------------------------------------------------------
[UIView animateWithDuration:0.5
delay:0
options:UIViewAnimationOptionBeginFromCurrentState
animations:^{
//Your Code For Animating Element.
}
completion:^(BOOL finished){
}];
---------------------------------------------------------------------------------
Example : 5
---------------------------------------------------------------------------------
[UIView animateWithDuration:0.5
delay:0
options:UIViewAnimationOptionBeginFromCurrentState
animations:^{
//Your Code For Animating Element.
}
completion:^(BOOL finished){
//Second Animation Block.
[UIView animateWithDuration:0.5
delay:0
options:UIViewAnimationOptionBeginFromCurrentState
animations:^{
completion:nil];
}];
---------------------------------------------------------------------------------
What Can Be Animated ?
Here is Some sample animation code that may useful to you.
Flip button with two image.
//First Click
[button setImage:[UIImage imageNamed:@"listimage.png"] forState:UIControlStateHighlighted];
[button setImage:[UIImage imageNamed:@"listimage.png"] forState:UIControlStateNormal];
[button setImage:[UIImage imageNamed:@"listimage.png"] forState:UIControlStateSelected];
[UIView beginAnimations:nil context:nil];
[UIView setAnimationDuration:0.75];
[UIView setAnimationDelegate:self];
[UIView setAnimationTransition:UIViewAnimationTransitionFlipFromLeft forView:btnListCal cache:YES];
[button setImage:[UIImage imageNamed:@"calandarimage.png"] forState:UIControlStateHighlighted];
[button setImage:[UIImage imageNamed:@"calandarimage.png"] forState:UIControlStateNormal];
[button setImage:[UIImage imageNamed:@"calandarimage.png"] forState:UIControlStateSelected];
[UIView commitAnimations];
//Second Click
[button setImage:[UIImage imageNamed:@"calandarimage.png"] forState:UIControlStateHighlighted];
[button setImage:[UIImage imageNamed:@"calandarimage.png"] forState:UIControlStateNormal];
[button setImage:[UIImage imageNamed:@"calandarimage.png"] forState:UIControlStateSelected];
[UIView beginAnimations:nil context:nil];
[UIView setAnimationDuration:0.75];
[UIView setAnimationDelegate:self];
[UIView setAnimationTransition:UIViewAnimationTransitionFlipFromRight forView:btnListCal cache:YES];
[button setImage:[UIImage imageNamed:@"listimage.png"] forState:UIControlStateHighlighted];
[button setImage:[UIImage imageNamed:@"listimage.png"] forState:UIControlStateNormal];
[button setImage:[UIImage imageNamed:@"listimage.png"] forState:UIControlStateSelected];
[UIView commitAnimations];
Explanation :
button is UIButton reference. The best example for fill button is in iPod Music application in iPhone.
Hope this will useful to you please share your trick and tip for UIAnimation. Thank You….:)
No comments:
Post a Comment