I want to create a simple animation changing alpha value:
[UIView beginAnimations:nil context:NULL];
[UIView setAnimationDuration:2];
[view1 setAlpha:0.00];
[UIView commitAnimations];
Ok in this way I change the alpha value for two seconds and it works fine, but I want this thing: When alpha is 0 the animation must should start another time to alpha = 1 So the animation should be: alpha 0 -> alpha 1 -> alpha 0 -> alpha 1 -> ... and so on with a duration of two seconds. Can you help me?
my complete code is
-(IBAction){
FirstViewController *firstViewController = [[[FirstViewController alloc] init]autorelease];
[firstViewController.label1 setAlpha:1.00];
[firstViewController.label2 setAlpha:1.00];
view = firstViewController.viewFirst; //this is my view and I copy in other view
[self fadeOut:nil finished:nil context:nil];}
- (void) fadeOut:(NSString *)animationID finished:(NSNumber *)finished context:(void *)context {
[UIView beginAnimations:nil context:NULL];
[UIView setAnimationDuration:2];
[UIView setAnimationDelegate:self];
[UIView setAnimationDidStopSelector:@selector(fadeIn:finished:context:) ];
[view setAlpha:0.00];
[UIView commitAnimations];
}
- (void) fadeIn:(NSString *)animationID finished:(NSNumber *)finished context:(void *)context {
[UIView beginAnimations:nil context:NULL];
[UIView setAnimationDuration:2];
[UIView setAnimationDelegate:self];
[UIView setAnimationDidStopSelector:@selector(fadeOut:finished:context:) ];
[view setAlpha:1.00];
[UIView commitAnimations];
}
In the Messages app , you can animate a single message with a bubble effect or fill the entire message screen with a full-screen effect (for example, balloons or confetti).
MotionSimply special effects. Motion is the powerful motion graphics tool that makes it easy to create cinematic 2D, 3D, and 360° titles, fluid transitions, and realistic effects in real time.
In iOS 4 and later you can do
view1.alpha = 1.0;
[UIView animateWithDuration:2.0
delay:0.0
options:UIViewAnimationOptionRepeat|UIViewAnimationAutoReverse
animations:^{
view1.alpha = 0.0;
}
completion:nil
];
- (void) fadeOut:(NSString *)animationID finished:(NSNumber *)finished context:(void *)context {
[UIView beginAnimations:nil context:NULL];
[UIView setAnimationDuration:2];
[UIView setAnimationDelegate:self];
if(animationRunning){
[UIView setAnimationDidStopSelector:@selector(fadeIn:finished:context:) ];
}
[view1 setAlpha:0.00];
[UIView commitAnimations];
}
- (void) fadeIn:(NSString *)animationID finished:(NSNumber *)finished context:(void *)context {
[UIView beginAnimations:nil context:NULL];
[UIView setAnimationDuration:2];
[UIView setAnimationDelegate:self];
if(animationRunning){
[UIView setAnimationDidStopSelector:@selector(fadeOut:finished:context:) ];
}
[view1 setAlpha:1.00];
[UIView commitAnimations];
}
These will call each other on the end of the animation...
All you need to do to start the ball rolling is call:
[self fadeOut:nil finished:nil context:nil];
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