0

I'm confused as to why this isn't working. I these three events to occur one after the other. First one zooms and Image out, second one fades in a background and third one animates the first image. But it actually occurs the other way round? Have I done something silly ?

    [UIView animateKeyframesWithDuration:2.0 delay:0.0 options:UIViewKeyframeAnimationOptionBeginFromCurrentState animations:^{
        [UIView addKeyframeWithRelativeStartTime:0.0 relativeDuration:0.25 animations:^{
            [v setFrame:CGRectMake(self.view.center.x - 125, self.view.center.y - 125, 250, 250)];
        }];
        [UIView addKeyframeWithRelativeStartTime:0.50 relativeDuration:0.75 animations:^{
            [UIView transitionWithView:self.fullView
                              duration:0
                               options:UIViewAnimationOptionTransitionCrossDissolve
                            animations:NULL
                            completion:NULL];

            [self.fullView setHidden:NO];
        }];
        [UIView addKeyframeWithRelativeStartTime:1.50 relativeDuration:0.5 animations:^{
            v.animationImages = [self.imageDict objectForKey:id];
            v.animationRepeatCount = 1;
            [v startAnimating];
        }];
    }
    completion:nil];

EDIT// Aside from the typo (1.50 for addKeyFrameWithRelativeStartTime), the third block wasn't working because the UIImageView startAnimating method needs to be placed in the completion block.

vanilla_splsh
  • 153
  • 1
  • 12

1 Answers1

3

Your code looks suspicious. The last key frame animation that you have added has a relative start time of 1.5. What does that do ? It should be within the range of 0 to 1.

From apple documentation,

frameStartTime

The time at which to start the specified animations. This value must be in the range 0 to 1, where 0 represents the start of the overall animation and 1 represents the end of the overall animation. For example, for an animation that is two seconds in duration, specifying a start time of 0.5 causes the animations to begin executing one second after the start of the overall animation.

frameDuration

The length of time over which to animate to the specified value. This value must be in the range 0 to 1 and indicates the amount of time relative to the overall animation length. If you specify a value of 0, any properties you set in the animations block update immediately at the specified start time. If you specify a nonzero value, the properties animate over that amount of time. For example, for an animation that is two seconds in duration, specifying a duration of 0.5 results in an animation duration of one second.

I am quite sure that fixing the value to be within the range will do some good change. But, I am not sure if it fixes your issue as I dont understand your animation code.

Sandeep
  • 20,908
  • 7
  • 66
  • 106
  • Oops the 1.5 was a typo - i've changed it to 0.5 now. The snippets from the docs are useful - I'll play round with that now. – vanilla_splsh Jan 14 '16 at 14:01