In my app, I need to set up an animation that will run on repeat until I perform an action on it. I want both an image to change, and text change along with it. I am trying now the suggested key frame animations, but it is only showing the last change and no repeats. I have done some searches and looking at the documentation, but I'm definitely still missing something.
It was my understanding that the animateKeyframesWithDuration
is measured in seconds, while relative start and relative duration are 0 - 1 in value, so I set each to be 0.2, as there are 5, and 0.2 is exactly a fifth. What am I doing wrong? All of the NSLogs fire, but none of the events actually change, other than the final one.
[UIView animateKeyframesWithDuration:70 delay:0 options:UIViewKeyframeAnimationOptionRepeat animations:^{
[UIView addKeyframeWithRelativeStartTime:0 relativeDuration:0.2 animations:^{
NSLog(@"a1");
self.eventsText.text = nil;
theImageView.image = [UIImage imageNamed:@"welcome.png"];
}];
[UIView addKeyframeWithRelativeStartTime:0.2 relativeDuration:0.2 animations:^{
NSLog(@"a12");
theImageView.image = [UIImage imageNamed:@"pleasepray.png"];
self.eventsText.text = @"Test2";
}];
[UIView addKeyframeWithRelativeStartTime:0.4 relativeDuration:0.2 animations:^{
NSLog(@"a13");
theImageView.image = [UIImage imageNamed:@"comingevents.png"];
self.eventsText.text = @"Test3";
}];
[UIView addKeyframeWithRelativeStartTime:0.6 relativeDuration:0.2 animations:^{
NSLog(@"a14");
theImageView.image = [UIImage imageNamed:@"birthdays.png"];
self.eventsText.text = nil;
}];
[UIView addKeyframeWithRelativeStartTime:0.8 relativeDuration:0.2 animations:^{
NSLog(@"a14");
theImageView.image = [UIImage imageNamed:@"ournumbers.png"];
self.eventsText.text = @"Test4";
}];
} completion:nil];