1
votes

I have a simple UIView animation block. In the block, I only change the view's alpha, but the view's frame is also being animated! WTF?

Here's my code:

UIButton *button = [flowerViews objectAtIndex:index];
UIImageView *newGlowView = [[UIImageView alloc] initWithImage:[UIImage imageNamed:@"grid_glow.png"]];
newGlowView.frame = CGRectMake(0, 0, 130, 130);
newGlowView.center = button.center;
newGlowView.alpha = 0.0;
[scrollView_ addSubview:newGlowView];
[scrollView_ sendSubviewToBack:newGlowView];
[UIView animateWithDuration:0.3 animations:^{
    newGlowView.alpha = 1.0;
}];

As you see, I'm creating a new view and adding it to scrollView_. I'm setting the view's position and alpha before adding it to scrollView_. Once it's added, I have an animation block to animate the view's alpha from 0 to 1.

The problem is, the view's position is also being animated! As it fades in, it looks as if it's animating from an original frame of CGRectZero to the one I've assigned it.

Ostensibly, only properties set within the animation block should be animated, right? Is this a bug? Am I missing something?

Thanks!

1
Is the whole thing being called from an animation block or maybe within an event that is within an animation block like the autorotate view controller delegate methods.mattjgalloway
Yes it is. Can you post that as an answer so I can accept it? I just figured this out myself (duh)CharlieMezak

1 Answers

1
votes

Perhaps the whole thing being called from an animation block or maybe within an event that is within an animation block like the autorotate view controller delegate methods.