I want to create a simple animation that changes the alpha value:
[UIView beginAnimations:nil context:NULL]; [UIView setAnimationDuration:2]; [view1 setAlpha:0.00]; [UIView commitAnimations];
Ok, so I change the alpha value for two seconds, and it works fine, but I want this thing: When alpha is 0, the animation should start another time before alpha = 1 Thus, the animation should be: alpha 0 → alpha 1 → alpha 0 → alpha 1 → ... and so on for two seconds. Can you help me?
my complete code
-(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]; }
CrazyDev
source share